【发布时间】:2021-08-18 17:28:09
【问题描述】:
美好的一天,我正在与 Google colab 一起训练模型,当我尝试运行这段代码时
history_1 = model_1.fit(x_train, y_train, epochs=1000, batch_size=16, validation_data=(x_validate, y_validate))
我得到错误:
ValueError Traceback (most recent call last)
<ipython-input-3-bd00c937585f> in <module>()
----> 1 history_1 = model_1.fit(x_train, y_train, epochs=1000, batch_size=16, validation_data=(x_validate, y_validate))
3 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training_utils.py in check_loss_and_target_compatibility(targets, loss_fns, output_shapes)
683 raise ValueError('A target array with shape ' + str(y.shape) +
684 ' was passed for an output of shape ' + str(shape) +
--> 685 ' while using as loss `' + loss_name + '`. '
686 'This loss expects targets to have the same shape '
687 'as the output.')
ValueError: A target array with shape (600, 1) was passed for an output of shape (None, 16) while using as loss `mean_squared_error`. This loss expects targets to have the same shape as the output.
我不确定我的输入有什么问题,我遵循 TinyML 书中的示例,有人可以帮助澄清如何解决这个问题吗?
【问题讨论】:
-
你需要分享模型
标签: tensorflow keras tf.keras