Keras: NameError: the name CVM is not defined

Created on 13 Feb 2017  路  1Comment  路  Source: keras-team/keras

Please make sure that the boxes below are checked before you submit your issue. If your issue is an implementation question, please ask your question on StackOverflow or join the Keras Slack channel and ask there instead of filing a GitHub issue.

Thank you!

  • [x] Check that you are up-to-date with the master branch of Keras. You can update with:
    pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps

  • [ ] If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.

  • [x] If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
    pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps

  • [x] Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).

I'm getting a NameError: the name CVM is not defined on a program that ran last week. The only thing I think I've done since then was to install quandl through Anaconda Navigator. I removed quandl, but I'm still getting the error.

I understand this is more likely something I screwed up, rather than a "bug", but I'd appreciate any help you can give me to get things back up and running.

Here is the full exception report:

runfile('E:/Python Files/Accuracy Error Demo.py', wdir='E:/Python Files')
Traceback (most recent call last):

File "", line 1, in
runfile('E:/Python Files/Accuracy Error Demo.py', wdir='E:/Python Files')

File "C:\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)

File "C:\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "E:/Python Files/Accuracy Error Demo.py", line 45, in
model.fit(X_train, y_train, batch_size=batch_size, nb_epoch=100)

File "C:\Anaconda3\lib\site-packages\keras\models.py", line 672, in fit
initial_epoch=initial_epoch)

File "C:\Anaconda3\lib\site-packages\keras\engine\training.py", line 1168, in fit
self._make_train_function()

File "C:\Anaconda3\lib\site-packages\keras\engine\training.py", line 767, in _make_train_function
**self._function_kwargs)

File "C:\Anaconda3\lib\site-packages\keras\backend\theano_backend.py", line 969, in function
return Function(inputs, outputs, updates=updates, **kwargs)

File "C:\Anaconda3\lib\site-packages\keras\backend\theano_backend.py", line 955, in __init__
**kwargs)

File "C:\Anaconda3\lib\site-packages\theano\compile\function.py", line 326, in function
output_keys=output_keys)

File "C:\Anaconda3\lib\site-packages\theano\compile\pfunc.py", line 486, in pfunc
output_keys=output_keys)

File "C:\Anaconda3\lib\site-packages\theano\compile\function_module.py", line 1795, in orig_function
defaults)

File "C:\Anaconda3\lib\site-packages\theano\compile\function_module.py", line 1661, in create
input_storage=input_storage_lists, storage_map=storage_map)

File "C:\Anaconda3\lib\site-packages\theano\gof\link.py", line 699, in make_thunk
storage_map=storage_map)[:3]

File "C:\Anaconda3\lib\site-packages\theano\gof\vm.py", line 1063, in make_all
impl=impl))

File "C:\Anaconda3\lib\site-packages\theano\scan_module\scan_op.py", line 892, in make_thunk
on_unused_input='ignore')

File "C:\Anaconda3\lib\site-packages\theano\compile\function.py", line 326, in function
output_keys=output_keys)

File "C:\Anaconda3\lib\site-packages\theano\compile\pfunc.py", line 486, in pfunc
output_keys=output_keys)

File "C:\Anaconda3\lib\site-packages\theano\compile\function_module.py", line 1795, in orig_function
defaults)

File "C:\Anaconda3\lib\site-packages\theano\compile\function_module.py", line 1661, in create
input_storage=input_storage_lists, storage_map=storage_map)

File "C:\Anaconda3\lib\site-packages\theano\gof\link.py", line 699, in make_thunk
storage_map=storage_map)[:3]

File "C:\Anaconda3\lib\site-packages\theano\gof\vm.py", line 1114, in make_all
self.updated_vars,

File "C:\Anaconda3\lib\site-packages\theano\gof\vm.py", line 968, in make_vm
vm = CVM(

NameError: ('The following error happened while compiling the node', forall_inplace,cpu,scan_fn}(TensorConstant{2}, InplaceDimShuffle{1,0,2}.0, IncSubtensor{InplaceSet;:int64:}.0, DeepCopyOp.0, TensorConstant{1}, lstm_6_U_o, lstm_6_U_f, lstm_6_U_i, lstm_6_U_c), '\n', "name 'CVM' is not defined")

And here is a sample program which generates the error (from my first bug report):

import numpy as np
from numpy.random import choice
from keras.layers import Dense
from keras.layers import LSTM
from keras.models import Sequential

batch_size = 2 
N_train = 100
N_test = 10

# CREATE SOME RANDOM DATA
X_train = np.ones((N_train, 2))
X_test = np.ones((N_test, 2))
y_train = np.ones((N_train, 1))
y_test = np.ones((N_test, 1))
one_indexes = choice(a=N_train, size=int(N_train / 2), replace=False)
X_train[one_indexes, 0] = -1
y_train[one_indexes] = -1
one_indexes = choice(a=N_test, size=int(N_test / 2), replace=False)
X_test[one_indexes, 0] = -1
y_test[one_indexes] = -1

# NORM THE DATA IN THE RANGE OF  -0.25 to 0.25      
### THIS IS WHAT CAUSES THE PROBLEM ###      
X_train *= 0.25
y_train *= 0.25
X_test *= 0.25
y_test *= 0.25      

X_train = np.expand_dims(X_train, axis=2)
X_test = np.expand_dims(X_test, axis=2)

# CREATE THE MODEL
model = Sequential()
model.add(LSTM(8, input_shape=(2, 1), return_sequences=False))
model.add(Dense(1, activation='tanh'))

model.compile(loss='mean_absolute_error', optimizer='adam', metrics=['accuracy'])

model.fit(X_train, y_train, batch_size=batch_size, nb_epoch=100)

# EVALUATE THE MODEL ON THE TEST DATA
score, acc = model.evaluate(X_test, y_test, batch_size=batch_size, verbose=0)
print()
print('Evaluate accuracy:', acc)
print()

# PREDICT THE MODEL ON THE TEST DATA
yFit = model.predict(X_test, batch_size=batch_size)

error = 0    
print('Prediction/Actual')
for c in range(X_test.shape[0]):
    error += yFit[c, 0] - y_test[c, 0]
    print(str(yFit[c]) + '  ' + str(y_test[c]))

error = abs(error)
print()
print('Predict error: ', error)
print('Predict accuracy: ', (1 - error))

Most helpful comment

The last comment on this thread solved the problem, ie. delete the C:\Users\username\AppData\Local\Theano directory

>All comments

The last comment on this thread solved the problem, ie. delete the C:\Users\username\AppData\Local\Theano directory

Was this page helpful?
0 / 5 - 0 ratings