我想使用 Tensorflow 和 Tensorboard V2 将精度和召回率合并到同一个图上。我找到了许多以前版本的示例,但没有一个适用于我的情况。
我创建了一个 Keras 回调来计算精度和召回率,然后调用张量流摘要将它们记录在同一个记录器中。我可以在 Tensorboard 中将它们可视化,但在 2 个独立的图中。
Class ClassificationReport(Callback):
def __init__(self, data_generator, steps, label_names, log_directory):
"""
Instantiator
:param data_generator: the data generator that produces the input data
:param steps: int, batch size
:param data_type, string, 'training', 'validation' or 'test', used a prefix in the logs
:param log_directory: pathlib2 path to the TensorBoard log directory
"""
self.data_generator = data_generator
self.steps = steps
self.data_type = data_type
self.logger = tensorflow.summary.create_file_writer(str(log_directory / self.data_type))
# names of the scalar …Run Code Online (Sandbox Code Playgroud)