textClassifier
textClassifier copied to clipboard
I meet an error,I do not know how to solve it ,please help me to solve it.
Traceback (most recent call last):
File "textClassifierRNN_ga.py", line 187, in
when I do not add the attention layer,there is not any error.But when I user the attention layer,there is the error.
I also face the same issue, not been able to solve it
Hi I also got the same error! anyone can help? @richliao can you point me to any root cause?
When running same script of CPU my model is compiled with no problems. On GPU, however, I am facing same issue. Could you please advice? Thanks! finalNet.compile(optimizer=opt, loss='categorical_crossentropy', metrics=['accuracy']) File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 899, in compile sample_weight, mask) File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 430, in weighted score_array = fn(y_true, y_pred) File "/usr/local/lib/python2.7/dist-packages/keras/losses.py", line 37, in categorical_crossentropy return K.categorical_crossentropy(y_pred, y_true) File "/usr/local/lib/python2.7/dist-packages/keras/backend/theano_backend.py", line 1400, in categorical_crossentropy return T.nnet.categorical_crossentropy(output, target) File "/usr/local/lib/python2.7/dist-packages/theano/tensor/nnet/nnet.py", line 2070, in categorical_crossentropy raise TypeError('rank mismatch between coding and true distributions') TypeError: rank mismatch between coding and true distributions
i met the same problem. Have you solved it? @rucJuanLi
It is because the difference between keras 1 and keras 2. I met the same problem and solved it by changing "get_output_shape_for" into "compute_output_shape" in the attention layer. However, later I met another problem and it could also be solved by https://stackoverflow.com/questions/47554275/typeerror-not-a-keras-tensor-elemwiseadd-no-inplace-0 @rucJuanLi