import matplotlib.pyplot as plt
import numpy as np
from keras import Sequential
from keras.callbacks import TensorBoard
from keras.layers import Dense
x = np.linspace(-10, 10, 300)
y = 3 * x + np.random.random(x.shape) * 0.44
model = Sequential()
model.add(Dense(1, activation='linear', input_shape=(1,)))
model.compile(optimizer='SGD', loss='mean_squared_error', metrics=['accuracy'])
model.summary()
model.fit(x, y, epochs=100, validation_split=0.3, verbose=2,
callbacks=[TensorBoard(log_dir='./logs', histogram_freq=1)])
这里直接使用了第一次试验的代码(简易线性回归),Tensorflow带的TensorBoard查看训练过程是非常的好用的,在keras里面,我们只需要在fit的时候加上一个callback让他产生日志就好啦
callbacks=[TensorBoard(log_dir='./logs', histogram_freq=1)]
训练结束之后,在命令行中执行
tensorboard --logdir=./logs
就可以查看训练过程了