gpt4 book ai didi

python - 为什么我的 tensorflow 的 model.evaluate() 会这样打印

转载 作者:行者123 更新时间:2023-12-04 10:52:04 25 4
gpt4 key购买 nike

model.fit()

打印

60000/60000 [==============================] - 10s 175us/sample - loss: 0.4940 - accuracy: 0.8262



这是正常的。但
model.evaluate()

打印

10000/1 [======.....10000times......=====] - 1s 117us/sample - loss: 0.2859 - accuracy: 0.8578



为什么?!

Error

However,  model.fit() prints normal

最佳答案

此问题已在 Tensorflow Version 中解决的 2.1-rc0 .

请找到以下代码,它可以解决问题:

!pip install tensorflow==2.1-rc0

import tensorflow as tf
from tensorflow import keras
print('Version of TensorFlow:', tf.__version__)
print('Version of tf.keras:', tf.keras.__version__)

# Import dataset
fashion_mnist = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()

# Build and Compile the model
model = keras.Sequential([
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy']
)

# Train the model
print('Training')
model.fit(train_images, train_labels, epochs=5)

# Evaluate the model
print('Evaluating')
test_loss, test_acc = model.evaluate(test_images, test_labels, verbose=1)
print('\nTest accuracy:', test_acc)

下图为执行日志截图:

enter image description here

关于python - 为什么我的 tensorflow 的 model.evaluate() 会这样打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59433456/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com