Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theano Error: 'TensorVariable' object has no attribute 'cast' #38

Open
ddofer opened this issue Jul 29, 2015 · 3 comments
Open

Theano Error: 'TensorVariable' object has no attribute 'cast' #38

ddofer opened this issue Jul 29, 2015 · 3 comments
Assignees

Comments

@ddofer
Copy link

ddofer commented Jul 29, 2015

Hi,
I'm trying to run the "example" on my own data.

After fitting the tokenizer, I get a big, long list of error messages from Theano.
Background: Windows 8.1. Anaconda + Python 2.7 64 bit. Latest Theano version, runs on GPU.
Passage installed from Pip.

Code:
tokenizer = Tokenizer( min_df=1, lowercase=False, character=False, max_features=10000)
X_train = tokenizer.fit_transform(X_train)
X_test = tokenizer.transform(X_test)
layers = [
Embedding(size=128, n_features=tokenizer.n_features),
GatedRecurrent(size=256, activation='tanh', gate_activation='steeper_sigmoid', init='orthogonal', seq_output=False),
Dense(size=1, activation='sigmoid', init='orthogonal') # sigmoid for binary classification
]
model = RNN(layers=layers, cost='bce')

Output:

'
ERROR (theano.gof.opt): Optimization failure due to: local_gpu_advanced_subtensor1
ERROR:theano.gof.opt:Optimization failure due to: local_gpu_advanced_subtensor1
ERROR (theano.gof.opt): TRACEBACK:
ERROR:theano.gof.opt:TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "d:\git\theano\theano\gof\opt.py", line 1485, in process_node
replacements = lopt.transform(node)
File "d:\git\theano\theano\sandbox\cuda\opt.py", line 980, in local_gpu_advanced_subtensor1
return [host_from_gpu(GpuAdvancedSubtensor1()(gpu_x, coords))]
File "d:\git\theano\theano\gof\op.py", line 507, in call
node = self.make_node(inputs, **kwargs)
File "d:\git\theano\theano\sandbox\cuda\basic_ops.py", line 2570, in make_node
ilist
= ilist
.cast('int64')
AttributeError: 'TensorVariable' object has no attribute 'cast'

ERROR:theano.gof.opt:Traceback (most recent call last):
File "d:\git\theano\theano\gof\opt.py", line 1485, in process_node
replacements = lopt.transform(node)
File "d:\git\theano\theano\sandbox\cuda\opt.py", line 980, in local_gpu_advanced_subtensor1
return [host_from_gpu(GpuAdvancedSubtensor1()(gpu_x, coords))]
File "d:\git\theano\theano\gof\op.py", line 507, in call
node = self.make_node(inputs, **kwargs)
File "d:\git\theano\theano\sandbox\cuda\basic_ops.py", line 2570, in make_node
ilist
= ilist
.cast('int64')
AttributeError: 'TensorVariable' object has no attribute 'cast'

ERROR (theano.gof.opt): Optimization failure due to: local_gpu_advanced_subtensor1
ERROR:theano.gof.opt:Optimization failure due to: local_gpu_advanced_subtensor1
ERROR (theano.gof.opt): TRACEBACK:
ERROR:theano.gof.opt:TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "d:\git\theano\theano\gof\opt.py", line 1485, in process_node
replacements = lopt.transform(node)
File "d:\git\theano\theano\sandbox\cuda\opt.py", line 974, in local_gpu_advanced_subtensor1
return [GpuAdvancedSubtensor1()(as_cuda_ndarray_variable(x), coords)]
File "d:\git\theano\theano\gof\op.py", line 507, in call
node = self.make_node(inputs, **kwargs)
File "d:\git\theano\theano\sandbox\cuda\basic_ops.py", line 2570, in make_node
ilist
= ilist
.cast('int64')
AttributeError: 'TensorVariable' object has no attribute 'cast'

ERROR:theano.gof.opt:Traceback (most recent call last):
File "d:\git\theano\theano\gof\opt.py", line 1485, in process_node
replacements = lopt.transform(node)
File "d:\git\theano\theano\sandbox\cuda\opt.py", line 974, in local_gpu_advanced_subtensor1
return [GpuAdvancedSubtensor1()(as_cuda_ndarray_variable(x), coords)]
File "d:\git\theano\theano\gof\op.py", line 507, in call
node = self.make_node(inputs, **kwargs)
File "d:\git\theano\theano\sandbox\cuda\basic_ops.py", line 2570, in make_node
ilist
= ilist
.cast('int64')
AttributeError: 'TensorVariable' object has no attribute 'cast'

ERROR (theano.gof.opt): Optimization failure due to: local_gpu_advanced_subtensor1
ERROR:theano.gof.opt:Optimization failure due to: local_gpu_advanced_subtensor1
ERROR (theano.gof.opt): TRACEBACK:
ERROR:theano.gof.opt:TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "d:\git\theano\theano\gof\opt.py", line 1485, in process_node
replacements = lopt.transform(node)
File "d:\git\theano\theano\sandbox\cuda\opt.py", line 974, in local_gpu_advanced_subtensor1
return [GpuAdvancedSubtensor1()(as_cuda_ndarray_variable(x), coords)]
File "d:\git\theano\theano\gof\op.py", line 507, in call
node = self.make_node(inputs, **kwargs)
File "d:\git\theano\theano\sandbox\cuda\basic_ops.py", line 2570, in make_node
ilist
= ilist
.cast('int64')
AttributeError: 'TensorVariable' object has no attribute 'cast'

ERROR:theano.gof.opt:Traceback (most recent call last):
File "d:\git\theano\theano\gof\opt.py", line 1485, in process_node
replacements = lopt.transform(node)
File "d:\git\theano\theano\sandbox\cuda\opt.py", line 974, in local_gpu_advanced_subtensor1
return [GpuAdvancedSubtensor1()(as_cuda_ndarray_variable(x), coords)]
File "d:\git\theano\theano\gof\op.py", line 507, in call
node = self.make_node(inputs, **kwargs)
File "d:\git\theano\theano\sandbox\cuda\basic_ops.py", line 2570, in make_node
ilist
= ilist
.cast('int64')
AttributeError: 'TensorVariable' object has no attribute 'cast'
'

  • This continues for hundreds of cases, repeating the error.
    Thanks!
@ddofer
Copy link
Author

ddofer commented Jul 29, 2015

Prediction also doesn't work of course.
model.fit(X_train,y_train)
Output:


ValueError Traceback (most recent call last)
in ()
----> 1 model.fit(X_train,y_train)

C:\Anaconda\lib\site-packages\passage\models.pyc in fit(self, trX, trY, batch_size, n_epochs, len_filter, snapshot_freq, path)
79 for e in range(n_epochs):
80 epoch_costs = []
---> 81 for xmb, ymb in self.iterator.iterXY(trX, trY):
82 c = self._train(xmb, ymb)
83 epoch_costs.append(c)

C:\Anaconda\lib\site-packages\passage\iterators.pyc in iterXY(self, X, Y)
67 for xmb, ymb in mb_chunks:
68 xmb = padded(xmb)
---> 69 yield self.x_dtype(xmb), self.y_dtype(ymb)

C:\Anaconda\lib\site-packages\passage\theano_utils.pyc in floatX(X)
6
7 def floatX(X):
----> 8 return np.asarray(X, dtype=theano.config.floatX)
9
10 def sharedX(X, dtype=theano.config.floatX, name=None):

C:\Anaconda\lib\site-packages\numpy\core\numeric.pyc in asarray(a, dtype, order)
460
461 """
--> 462 return array(a, dtype, copy=False, order=order)
463
464 def asanyarray(a, dtype=None, order=None):

ValueError: could not convert string to float: C

@youralien
Copy link

Tried looking up your error,

AttributeError: 'TensorVariable' object has no attribute 'cast'

and it might be related to the issue encountered on this stack overflow post:
http://stackoverflow.com/questions/19489259/accessing-data-of-a-theano-shared-variable

Try updating Theano again through conda

conda update conda
conda update Theano

or perhaps set DYLD_FALLBACK_LIBRARY_PATH="/Users/Me/anaconda/lib" per the stack overflow question? Please let me know how it goes, getting packages working on different systems is always a challenge that is not fun, IMO!

@ddofer
Copy link
Author

ddofer commented Aug 7, 2015

That worked, thanks!

On Fri, Aug 7, 2015 at 8:24 AM, Ryan Louie [email protected] wrote:

Tried looking up your error,

AttributeError: 'TensorVariable' object has no attribute 'cast'

and it might be related to the issue encountered on this stack overflow
post:

http://stackoverflow.com/questions/19489259/accessing-data-of-a-theano-shared-variable

Try updating Theano again through conda

conda update conda
conda update Theano

or perhaps set DYLD_FALLBACK_LIBRARY_PATH="/Users/Me/anaconda/lib" per
the stack overflow question? Please let me know how it goes, getting
packages working on different systems is always a challenge that is not
fun, IMO!


Reply to this email directly or view it on GitHub
#38 (comment)
.

Dan Ofer - דן עופר
Publications http://scholar.google.co.il/citations?hl=en&user=uDx2ItYAAAAJ

Photography
http://picasaweb.google.com/ddofer
http://500px.com/DanOfer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants