我在CNN的自定义丢失方面遇到问题。在模型编译期间没有错误,但是当我在模型中放置训练集时会显示错误。我想知道为什么y_pred和y_true之间发生形状不匹配。请让我知道该怎么办
Epoch 1/5
Traceback (most recent call last):
File "model", line 184, in <module>
result=model.fit(train_image,train_label,batch_size=3,epochs=5,callbacks=[earlystopper,checkpointer])
File "/home/apple/anaconda2/lib/python2.7/site-packages/tensorflow/python/keras/engine/training.py", line 880, in fit
validation_steps=validation_steps)
File "/home/apple/anaconda2/lib/python2.7/site-packages/tensorflow/python/keras/engine/training_arrays.py", line 329, in model_iteration
batch_outs = f(ins_batch)
File "/home/apple/anaconda2/lib/python2.7/site-packages/tensorflow/python/keras/backend.py", line 3076, in __call__
run_metadata=self.run_metadata)
File "/home/apple/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1439, in __call__
run_metadata_ptr)
File "/home/apple/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.py", line 528, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [3,364,444,1] vs. [3,180,260,2]
[[{{node loss/conv2d_18_loss/sub}}]]
[[{{node loss/mul}}]]