def write_log(callback, names, logs, batch_no): for name, value in zip(names, logs): summary = tf.Summary() summary_value = summary.value.add() summary_value.simple_value = value summary_value.tag = name callback.writer.add_summary(summary, batch_no) callback.writer.flush()
在訓練的時候,調用上述函數,寫入tensorboard函數
loss = model.train_on_batch([x1,x2],y) write_log(tensorboard_cb,["trainloss","me"],loss,bathNo)