ValueError:检查目标时出错:预期密集_2的形状为(2,),但数组的形状为(1,)

时间:2020-07-06 21:01:02

标签: python tensorflow keras

我正在加载Keras并收到此ValueError。我浏览了各个论坛,但仍然陷入困境。 keras error:Error when checking target: expected dense_2 to have shape (2,) but got array with shape (1,)

似乎正在讨论课程,但是我不确定这是如何相关的。如果有人可以指导我,我将不胜感激。我是一个初学者,刚开始学习如何使用Keras。

'''

epochs=10
history = model.fit_generator(
    train_generator, 
    epochs=epochs,
    validation_data=validation_generator,
    validation_steps=total_validate//batch_size,
    steps_per_epoch=total_train//batch_size,
    callbacks=callbacks
)

'''

'''

Epoch 1/10
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-14-f7b6d0c9c94b> in <module>()
      6     validation_steps=total_validate//batch_size,
      7     steps_per_epoch=total_train//batch_size,
----> 8     callbacks=callbacks
      9 )

5 frames
/usr/.../training_utils.py in standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix)
    143                             ': expected ' + names[i] + ' to have shape ' +
    144                             str(shape) + ' but got array with shape ' +
--> 145                             str(data_shape))
    146     return data
    147 

ValueError: Error when checking target: expected dense_2 to have shape (2,) but got array with shape (1,)

'''

0 个答案:

没有答案