• Tensorflow训练FashionMnist数据集报错:
    WARNING:tensorflow:Model was constructed with shape (None, 28, 28) for input KerasTensor(type_spec=TensorSpec(shape=(None, 28, 28), dtype=tf.float32, name=‘flatten_input’), name=‘flatten_input’, description=“created by layer ‘flatten_input’”), but it was called on an input with incompatible shape (None, 28).
    在这里插入图片描述
  • 解决方案:
    代码修改:
    在这里插入图片描述
    使用reshape(1, 28, 28)
print(np.argmax(model.predict([[(test_images[0]/255).reshape(1, 28, 28)]])))
  • 成功运行
    模型训练的不错,预测值与标签值相同
    在这里插入图片描述
Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐