Skip to content

Commit

Permalink
Support abnormal scalar value
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenYuhan authored Jun 10, 2021
1 parent e33f684 commit 5f2f576
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions visualdl/server/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import os
import io
import csv
import math
import numpy as np
from visualdl.server.log import logger
from visualdl.io import bfile
Expand All @@ -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)
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 5f2f576

Please sign in to comment.