我刚刚开始使用Tensorflow,但我有点错误。
cifar10_mnist = keras.datasets.cifar10
(train_images, train_labels), (test_images, test_labels) = cifar10_mnist.load_data()
train_images = train_images/255
test_images = test_images/255
classes = ['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship',
'truck']
model = keras.Sequential([
keras.layers.Flatten(input_shape=(32,32)),
keras.layers.Dense(150, activation="relu"),
keras.layers.Dense(10, activation="softmax")
])
model.compile(optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"])
model.fit(train_images, train_labels, epochs=5)
test_loss, test_acc = model.evaluate(test_images, test_labels)
prediction = model.predict(test_images)
answer = np.argmax(prediction[0])
print(classes[answer])
我不太确定如何解决此问题,我一直在回头,但看不到可以更改的任何解决方法。谢谢,非常感谢您的帮助。 :)