首页 > 解决方案 > Tensorboard 不显示所有训练数据

问题描述

您好,我对神经网络比较陌生。我正在尝试通过张量板绘制我的训练和验证数据的 MAE。然而,张量板只显示了一小部分训练数据。它显示了所有的验证数据。我还使用matplotlib绘制历史,一切都是正确的。下面是我的代码和图表。有什么问题,我该如何解决?先感谢您。

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from tensorflow import keras
from datetime import datetime


#  ---------train the neural network-----------
model = keras.Sequential([  # Sequential training function
    keras.layers.Dense(30, activation="relu", kernel_initializer='random_uniform',
                       bias_initializer='zeros', input_shape=(2,), name="input"),  # input layer
    keras.layers.Dense(30, activation="relu", name="hidden_1"),  # the first hidden layer with 30 neurons
    keras.layers.Dense(30, activation="relu", name="hidden_2"),  # the second hidden layer with 30 neurons
    keras.layers.Dense(1, name="output")  # the output layer with 1 neuron since there is only one output
])
epochs = 500
optimizer = keras.optimizers.Adam(learning_rate=0.001, beta_1=0.9, beta_2=0.999, amsgrad=True)  # define the optimizer
tb = keras.callbacks.TensorBoard(log_dir=r"C:\Users\Beichao\Desktop\BEICHAO\Neural Network\python code\regression"
                                 .format(datetime.now()))

model.compile(loss="mean_squared_error", optimizer=optimizer, metrics=['mae'])  # define some parameters
history = model.fit(x_train, y_train, batch_size=32, validation_data=[x_validation, y_validation]
                    , epochs=epochs, verbose=0, callbacks=[tb])  # train the NN
error = model.evaluate(x_validation, y_validation)
print(f"mean absolute error is {error}")

张量板图

matplotlib 图

标签: pythontensorflowkerastensorboard

解决方案


推荐阅读