未验证 提交 5f2f5761 编写于 作者: 走神的阿圆's avatar 走神的阿圆 提交者: GitHub

Support abnormal scalar value

上级 e33f6848
......@@ -20,6 +20,7 @@ import time
import os
import io
import csv
import math
import numpy as np
from visualdl.server.log import logger
from visualdl.io import bfile
......@@ -39,6 +40,12 @@ def s2ms(timestamp):
return timestamp * 1000 if timestamp < 2000000000 else timestamp
def transfer_abnomal_scalar_value(scalar_value):
if math.isnan(scalar_value) or math.isinf(scalar_value):
scalar_value = str(scalar_value)
return scalar_value
def get_components(log_reader):
components = log_reader.components(update=True)
return list(components)
......@@ -238,7 +245,7 @@ def get_hparam_metric(log_reader, run, tag):
log_reader.load_new_data()
records = log_reader.data_manager.get_reservoir("scalar").get_items(
run, decode_tag(tag))
results = [[s2ms(item.timestamp), item.id, item.value] for item in records]
results = [[s2ms(item.timestamp), item.id, transfer_abnomal_scalar_value(item.value)] for item in records]
return results
......@@ -288,7 +295,7 @@ def get_scalar(log_reader, run, tag):
log_reader.load_new_data()
records = log_reader.data_manager.get_reservoir("scalar").get_items(
run, decode_tag(tag))
results = [[s2ms(item.timestamp), item.id, item.value] for item in records]
results = [[s2ms(item.timestamp), item.id, transfer_abnomal_scalar_value(item.value)] for item in records]
return results
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册