Lorraine333 / ACL_CKBC

22 stars 6 forks source link

AttributeError: 'SharedVariable' object has no attribute 'astype' #1

Closed kaharjan closed 7 years ago

kaharjan commented 7 years ago

Thank you for your sharing your code. But when I am running code I encounter the below problem: do you have any ideas what is wrong? thank you!!!

packages/theano/tensor/signal/downsample.py:6: UserWarning: downsample module has been moved to the theano.tensor.signal.pool module.
  "downsample module has been moved to the theano.tensor.signal.pool module.")
Using Training Data../commonsendata/Training/new_omcs100.txt
Using Word Embeddings with Dimension 200
Training on 1000 examples using lambda=1e-05
Saving models to: ../models/Bilinear_cetrainSize300frac0.01dSize200relSize150acti0.001.1e-05.200.RAND.tanh.txt
Traceback (most recent call last):
  File "train.py", line 80, in <module>
    tm = theano_word_model(We, words, params.embedsize, rel, params.relsize, Rel_init, params.LC, params.Lw, params.eta, params.margin, params.usepeep, params.activation)
  File "/home/kaharjan/kbGit/ACL_CKBC/bilinear_ce/commonsense.py", line 243, in __init__
    self.we = theano.shared(We_initial).astype(theano.config.floatX)
AttributeError: 'SharedVariable' object has no attribute 'astype'
/home/kaharjan/python-env/gpu/local/lib/python2.7/site-packages/theano/tensor/signal/downsample.py:6: UserWarning: downsample module has been moved to the theano.tensor.signal.pool module.
  "downsample module has been moved to the theano.tensor.signal.pool module.")
Using Training Data../commonsendata/Training/new_omcs100.txt
Using Word Embeddings with Dimension 200
Training on 1000 examples using lambda=1e-05
Saving models to: ../models/Bilinear_cetrainSize300frac0.01dSize200relSize150acti0.001.1e-05.200.MIX.tanh.txt
Traceback (most recent call last):
  File "train.py", line 80, in <module>
    tm = theano_word_model(We, words, params.embedsize, rel, params.relsize, Rel_init, params.LC, params.Lw, params.eta, params.margin, params.usepeep, params.activation)
  File "/home/kaharjan/kbGit/ACL_CKBC/bilinear_ce/commonsense.py", line 243, in __init__
    self.we = theano.shared(We_initial).astype(theano.config.floatX)
AttributeError: 'SharedVariable' object has no attribute 'astype'
/home/kaharjan/python-env/gpu/local/lib/python2.7/site-packages/theano/tensor/signal/downsample.py:6: UserWarning: downsample module has been moved to the theano.tensor.signal.pool module.
  "downsample module has been moved to the theano.tensor.signal.pool module.")
Using Training Data../commonsendata/Training/new_omcs100.txt
Using Word Embeddings with Dimension 200
Training on 1000 examples using lambda=1e-05
Saving models to: ../models/Bilinear_cetrainSize300frac0.01dSize200relSize150acti0.001.1e-05.200.MAX.tanh.txt
Traceback (most recent call last):
  File "train.py", line 80, in <module>
    tm = theano_word_model(We, words, params.embedsize, rel, params.relsize, Rel_init, params.LC, params.Lw, params.eta, params.margin, params.usepeep, params.activation)
  File "/home/kaharjan/kbGit/ACL_CKBC/bilinear_ce/commonsense.py", line 243, in __init__
    self.we = theano.shared(We_initial).astype(theano.config.floatX)
AttributeError: 'SharedVariable' object has no attribute 'astype'
Lorraine333 commented 7 years ago

Hi kaharjan: Thanks for using our code. I believe it's a version compatibility issue. Would you mind telling me which version of python and theono you are using?

Thanks, Xiang

kaharjan commented 7 years ago

Originally my Theano version should be 0.81, then I upgraded it to 0.82, python is 2.7.6, also upgraded Scipy to 0.19.0. the problem is the same. Thank you for your reply. I wish you could give advises.

Lorraine333 commented 7 years ago

Hi, sorry for the late reply.

I run it on my machine and on another machine using linux system, the code both works. My theano version is 0.82, python version 2.7.6, scipy version 0.15.1, numpy version 0.11.2.

The other machine has the same theano and python version but has scipy verison 0.18.1, numpy version 0.12.0.

Maybe can you try with these version configurations? Also, are you downloading the embedding from this page http://ttic.uchicago.edu/~kgimpel/commonsense.html of embeddings.txt.gz?

Hope that helps, let me know if you still have issue.

kaharjan commented 7 years ago

Thank you. Problem is solved, it is the problem of word2vec file format problem.