1. 实验
"""
test tensorboard basic demo
"""
from keras.layers import Dense
from keras.models import Sequential
from keras.callbacks import TensorBoard
import numpy as np
model = Sequential()
model.add(Dense(units=64, activation='relu', input_shape=(3,), name="dense1"))
model.add(Dense(units=1, name="dense2"))
model.compile(loss='binary_crossentropy',
optimizer='sgd',
metrics=['accuracy'])
x_train = np.array([[1, 2, 3], [4, 5, 6]])
y_train = np.array([1, 0])
model.fit(x_train, y_train, epochs=5, batch_size=32,
callbacks=[
TensorBoard(
log_dir="/tmp/test_tensorboard_dashboard", write_graph=True)]
)
# 最终通过 tensorboard --logdir=/tmp/test_tensorboard_dashboard 进行查看。
2. tensorboard的具体结构图
权重随机初始化
赋值操作
bias赋值操作
metrics中准确率的具体计算
logloss的具体计算
损失求参数求梯度,并对相应参数进行更新和赋值