我正在Ubuntu python 2.7.15上使用Keras 2.2.2和tensorflow 1.11.0后端。
该模型是带有CRF的NER的Bi-LSTM。训练工作正常,但是model.evaluate会显示以下错误消息(请注意,如果我删除了CRF层,它将起作用。)
有什么办法解决吗?
pred_probs,x和y是numpy数组。
pred_probs = model.predict(x)
test_loss = model.evaluate(x, y, batch_size=1, verbose=0)
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-0811297abd37>", line 58, in <module>
num_epochs=opts.nbepochs)
File "<ipython-input-3-3e6f3e16f5a8>", line 370, in run_model_fixedembed
maxlen, fileprefix=fileprefix)
File "<ipython-input-3-3e6f3e16f5a8>", line 136, in predict_score
test_loss = model.evaluate(x, y, batch_size=1, verbose=0)
File "/home/ubuntu/.local/lib/python2.7/site-packages/keras/engine/training.py", line 1111, in evaluate
steps=steps)
File "/home/ubuntu/.local/lib/python2.7/site-packages/keras/engine/training_arrays.py", line 392, in test_loop
batch_outs = f(ins_batch)
File "/home/ubuntu/.local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 2666, in __call__
return self._call(inputs)
File "/home/ubuntu/.local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 2636, in _call
fetched = self._callable_fn(*array_vals)
File "/home/ubuntu/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1399, in __call__
run_metadata_ptr)
File "/home/ubuntu/.local/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.py", line 526, in __exit__
c_api.TF_GetCode(self.status.status))
InvalidArgumentError: You must feed a value for placeholder tensor 'bidirectional_1_input' with dtype float and shape [?,36,400]
[[{{node bidirectional_1_input}} = Placeholder[dtype=DT_FLOAT, shape=[?,36,400], _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]