Tensorflow报错:WARNING:tensorflow:Model was constructed with shape (None, 28, 28) for input Keras

  • 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).
    Tensorflow报错:WARNING:tensorflow:Model was constructed with shape (None, 28, 28) for input Keras_第1张图片
  • 解决方案:
    代码修改:
    在这里插入图片描述
    使用reshape(1, 28, 28)
print(np.argmax(model.predict([[(test_images[0]/255).reshape(1, 28, 28)]])))
  • 成功运行
    模型训练的不错,预测值与标签值相同
    Tensorflow报错:WARNING:tensorflow:Model was constructed with shape (None, 28, 28) for input Keras_第2张图片

你可能感兴趣的:(学习中遇到的问题,tensorflow,Fashion,Mnist,计算机视觉)