python - 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}")
解决方案
推荐阅读
- javascript - 如何将数组作为路径参数传递并根据每个数组值获取响应
- java - 文件名.println(String); 跳过每隔一行
- sockets - sbatch:错误:批处理作业提交失败:运行 Snakemake 时,套接字在发送/接收操作时超时
- r - How to use is.na function with dates
- java - Browser wont identify HTTP response header?
- ruby-on-rails - Heroku Rails 6 multiple connection not working
- python - 文件“C:\Python38-32\lib\os.py”,第 411 行语法错误
- react-native - Expo - AppLoading threw an unexpected error when loading
- php - 如何增加会话数组值?
- c# - 使用 Entity Framework sql 将 Null 插入数据库