我遵循张力板教程,它不工作。。。你知道吗
教程在这里:https://www.tensorflow.org/tensorboard/get_started
当我安装模型时,会出现以下警告: 警告:tensorflow:与批量更新(0.168042)相比,方法(在\u列\u批处理\u端)比较慢。检查您的回电。
只有在我使用tf.keras.回调.TensorBoard(用于记录培训)。你知道吗
然后,似乎张力板无法绘制如图托所示的训练图,而只能绘制验证图。你知道吗
我用TensorFlow2.0.0和TensorFlowGPU2.0.0进行了测试。同样的问题。你知道吗
C:\Users\X>conda list tensor
# packages in environment at C:\Users\X\Miniconda3:
#
# Name Version Build Channel
tensorboard 2.0.0 pyhb38c66f_1
tensorflow 2.0.0 mkl_py37he1bbcac_0
tensorflow-base 2.0.0 mkl_py37hd1d5974_0
tensorflow-estimator 2.0.0 pyh2649769_0
(tf-gpu) >conda list tensor
# packages in environment at C:\Users\X\Miniconda3\envs\tf-gpu:
#
# Name Version Build Channel
tensorboard 2.0.0 pyhb38c66f_1
tensorflow 2.0.0 gpu_py37h57d29ca_0
tensorflow-base 2.0.0 gpu_py37h390e234_0
tensorflow-estimator 2.0.0 pyh2649769_0
tensorflow-gpu 2.0.0 h0d30ee6_0
使用的代码:
mnist = tf.keras.datasets.mnist
(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
def create_model():
return tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(512, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation='softmax')
])
model = create_model()
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
# only change vs tutorial, because Windows
# log_dir="./logs/fit/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
log_dir="logs\\fit\\" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir,
histogram_freq=1)
model.fit(x=x_train,
y=y_train,
epochs=5,
validation_data=(x_test, y_test),
callbacks=[tensorboard_callback])
Train on 60000 samples, validate on 10000 samples
Epoch 1/5
32/60000 [..............................] - ETA: 22:46 - loss: 2.4036 - accuracy: 0.0625
WARNING:tensorflow:Method (on_train_batch_end) is slow compared to the batch update (0.168042). Check your callbacks.
60000/60000 [==============================] - 9s 144us/sample - loss: 0.2177 - accuracy: 0.9348 - val_loss: 0.1144 - val_accuracy: 0.9650
Epoch 2/5
60000/60000 [==============================] - 7s 122us/sample - loss: 0.0961 - accuracy: 0.9707 - val_loss: 0.0727 - val_accuracy: 0.9776
Epoch 3/5
60000/60000 [==============================] - 8s 125us/sample - loss: 0.0677 - accuracy: 0.9785 - val_loss: 0.0744 - val_accuracy: 0.9755
Epoch 4/5
60000/60000 [==============================] - 7s 121us/sample - loss: 0.0529 - accuracy: 0.9830 - val_loss: 0.0746 - val_accuracy: 0.9763
Epoch 5/5
60000/60000 [==============================] - 7s 123us/sample - loss: 0.0441 - accuracy: 0.9859 - val_loss: 0.0675 - val_accuracy: 0.9815
<tensorflow.python.keras.callbacks.History at 0x15f0ff63548>
你知道吗?你知道吗
谢谢!你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐