ruidan / Unsupervised-Aspect-Extraction

Code for acl2017 paper "An unsupervised neural attention model for aspect extraction"
Apache License 2.0
338 stars 117 forks source link

AttributeError: 'Dimension' object has no attribute 'eval' #13

Closed rashindrie closed 4 years ago

rashindrie commented 6 years ago

Im getting an AttributeError: 'Dimension' object has no attribute 'eval' when trying to train. Can someone assist me to solve this issue.

 File "train.py", line 107, in <module>
    model = create_model(args, overall_maxlen, vocab)
  File "/home/src/Unsupervised-Aspect-Extraction/code/model.py", line 43, in create_model
    W_regularizer=ortho_reg)(p_t)
  File "/home/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 592, in __call__
    self.build(input_shapes[0])
  File "/home/src/Unsupervised-Aspect-Extraction/code/my_layers.py", line 127, in build
    constraint=self.W_constraint)
  File "/home/.local/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/home/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 418, in add_weight
    self.add_loss(regularizer(weight))
File "/home/src/Unsupervised-Aspect-Extraction/code/model.py", line 17, in ortho_reg
    reg = K.sum(K.square(K.dot(w_n, K.transpose(w_n)) - K.eye(w_n.shape[0].eval())))
AttributeError: 'Dimension' object has no attribute 'eval'
ruidan commented 6 years ago

Can you follow the Dependencies section in README and check if the versions are correct?

DasonBryant commented 5 years ago

What's the version of tensorflow

agarnitin86 commented 5 years ago

Were you able to solve the issue, i am getting same error.. i am using keras 2.2.4 and trying to update the code to work with this version.... Any help please ?

yaocheng95 commented 5 years ago

The same problem here.

yaocheng95 commented 5 years ago

Can you follow the Dependencies section in README and check if the versions are correct?

What;s the tensorflow version?

ruidan commented 5 years ago

The code was developed using Keras 1.2.1 with theano 0.9.0 as the backend (not tensorflow).

johnnyjana730 commented 4 years ago

same issue

tawhidwasik08 commented 4 years ago

For Windows users using Anaconda. Open the Anaconda Prompt and type: set "KERAS_BACKEND=theano"