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

Dimensions must be equal, but are 15 and 100 for 'att_layer_2/mul' (op: 'Mul') with input shapes: [?,15], [?,15,100]. #37

Open
asherxyw opened this issue Nov 20, 2018 · 12 comments

Comments

@asherxyw
Copy link

When I ran by using python textClassifierHATT.py in Anaconda, I got this error:
Using TensorFlow backend.
(25000, 3)
textClassifierHATT.py:56: UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html.parser"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.

The code that caused this warning is on line 56 of the file textClassifierHATT.py. To get rid of this warning, pass the additional argument 'features="html.parser"' to the BeautifulSoup constructor.

text = BeautifulSoup(data_train.review[idx])
/home/user/anaconda3/envs/py27_env/lib/python2.7/site-packages/keras_preprocessing/text.py:177: UserWarning: The nb_words argument in Tokenizer has been renamed num_words.
warnings.warn('The nb_words argument in Tokenizer '
Total 80568 unique tokens.
('Shape of data tensor:', (25000, 15, 100))
('Shape of label tensor:', (25000, 2))
Number of positive and negative reviews in traing and validation set
[10026. 9974.]
[2474. 2526.]
Total 400000 word vectors.
2018-11-20 09:49:08.166457: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Traceback (most recent call last):
File "textClassifierHATT.py", line 188, in
l_att_sent = AttLayer(100)(l_lstm_sent)
File "/home/user/anaconda3/envs/py27_env/lib/python2.7/site-packages/keras/engine/base_layer.py", line 457, in call
output = self.call(inputs, **kwargs)
File "textClassifierHATT.py", line 167, in call
ait *= K.cast(mask, K.floatx())
File "/home/user/anaconda3/envs/py27_env/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 866, in binary_op_wrapper
return func(x, y, name=name)
File "/home/user/anaconda3/envs/py27_env/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 1131, in _mul_dispatch
return gen_math_ops.mul(x, y, name=name)
File "/home/user/anaconda3/envs/py27_env/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 5042, in mul
"Mul", x=x, y=y, name=name)
File "/home/user/anaconda3/envs/py27_env/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/home/user/anaconda3/envs/py27_env/lib/python2.7/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "/home/user/anaconda3/envs/py27_env/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op
op_def=op_def)
File "/home/user/anaconda3/envs/py27_env/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1792, in init
control_input_ops)
File "/home/user/anaconda3/envs/py27_env/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1631, in _create_c_op
raise ValueError(str(e))
ValueError: Dimensions must be equal, but are 15 and 100 for 'att_layer_2/mul' (op: 'Mul') with input shapes: [?,15], [?,15,100].
What was going wrong?Can anyone help me?

@uchaoxi
Copy link

uchaoxi commented Dec 8, 2018

I have the same problem

@snsxf
Copy link

snsxf commented Dec 12, 2018

Me,too

@snsxf
Copy link

snsxf commented Dec 12, 2018

compute_mask (): return None

@asherxyw
Copy link
Author

compute_mask (): return None

I got that errors when I used the version of python is 3.5,Then I change the version to 2.7, and the error didn't occur.

@tingfang2018
Copy link

I change the version to 2.7, the error still occurs. How to deal with it?

@asherxyw
Copy link
Author

I change the version to 2.7, the error still occurs. How to deal with it?
You need to change the version of your keras to 2.0.8, and don't use the latest version.

@yiqingzhang
Copy link

I met the same issue

@asherxyw
Copy link
Author

I met the same issue

Make sure the version of keras is 2.0.8 and the version of python is 2.7

@srivianand987
Copy link

compute_mask (): return None

Thanks, this worked for me with Python3.6

@sachinh35
Copy link

compute_mask (): return None

Worked, thanks 😃

@yaoguangzi
Copy link

compute_mask (): return None

python 3.7, worked, thanks

@Zhouyuan-Chen
Copy link

compute_mask (): return None

WORKED!!!!

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

9 participants