[英]Keras - plot values to tensorboard
I have the following code (using Keras): 我有以下代码(使用Keras):
self.tensorboard = TensorBoard(log_dir='./logs', histogram_freq=0,
write_graph=False, write_images=True)
input_ = Input(shape=self.s_dim, name='input')
hidden = Dense(self.n_hidden, activation='relu')(input_)
out = Dense(3, activation='softmax')(hidden)
model = Model(inputs=input_, outputs=out, name="br-model")
model.compile(loss='mean_squared_error', optimizer=SGD(lr=0.005), metrics=['accuracy'])
# Some stuff in-between
model.fit(batch, target, epochs=2, verbose=0, callbacks=[self.tensorboard])
for k in batch:
exploitability.append(np.max(model.predict(batch[k]))
It plot's the loss and the accuracy to tensorboard. 它绘制到张量板的损耗和精度。
But i want to plot the np.average(exploitabilty)
as well to tensorboard - how does it work? 但是我也想将
np.average(exploitabilty)
绘制到张量板上-它是如何工作的? Is there any possibility to pass it as a metric or something similar? 是否有可能将其作为指标或类似指标传递?
You can add custom metrics to your model when you compile it, eg: 您可以在编译模型时向模型添加自定义指标,例如:
def custom_metric(y_true, y_pred):
max = K.max(y_pred)
return max
model.compile(loss='mean_squared_error', optimizer=SGD(lr=0.005),
metrics=['accuracy', custom_metric])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.