IndicoDataSolutions / Passage

A little library for text analysis with RNNs.
MIT License
531 stars 134 forks source link

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

Open ddofer opened 9 years ago

ddofer commented 9 years ago

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 makenode 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 makenode 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 makenode 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 makenode 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 makenode 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 makenode ilist = ilist_.cast('int64') AttributeError: 'TensorVariable' object has no attribute 'cast' '

ddofer commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

That worked, thanks!

On Fri, Aug 7, 2015 at 8:24 AM, Ryan Louie notifications@github.com 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 https://github.com/IndicoDataSolutions/Passage/issues/38#issuecomment-128602106 .

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

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