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

s2ms (#781)

上级 52f26263
......@@ -22,6 +22,10 @@ from visualdl.io import bfile
from visualdl.utils.string_util import encode_tag, decode_tag
def s2ms(timestamp):
return timestamp * 1000 if timestamp < 2000000000 else timestamp
def get_components(log_reader):
components = log_reader.components(update=True)
components.add('graph')
......@@ -77,7 +81,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 = [[item.timestamp, item.id, item.value] for item in records]
results = [[s2ms(item.timestamp), item.id, item.value] for item in records]
return results
......@@ -92,7 +96,7 @@ def get_image_tag_steps(log_reader, run, tag):
run, decode_tag(tag))
result = [{
"step": item.id,
"wallTime": item.timestamp
"wallTime": s2ms(item.timestamp)
} for item in records]
return result
......@@ -116,7 +120,7 @@ def get_audio_tag_steps(log_reader, run, tag):
run, decode_tag(tag))
result = [{
"step": item.id,
"wallTime": item.timestamp
"wallTime": s2ms(item.timestamp)
} for item in records]
return result
......@@ -152,7 +156,7 @@ def get_pr_curve(log_reader, run, tag):
pr_curve = item.pr_curve
length = len(pr_curve.precision)
num_thresholds = [float(v) / length for v in range(1, length + 1)]
results.append([item.timestamp,
results.append([s2ms(item.timestamp),
item.id,
list(pr_curve.precision),
list(pr_curve.recall),
......@@ -171,7 +175,7 @@ def get_pr_curve_step(log_reader, run, tag=None):
log_reader.load_new_data()
records = log_reader.data_manager.get_reservoir("pr_curve").get_items(
run, decode_tag(tag))
results = [[item.timestamp, item.id] for item in records]
results = [[s2ms(item.timestamp), item.id] for item in records]
return results
......@@ -213,7 +217,7 @@ def get_histogram(log_reader, run, tag):
histogram_data = []
for index in range(len(hist)):
histogram_data.append([bin_edges[index], bin_edges[index+1], hist[index]])
results.append([item.timestamp, item.id, histogram_data])
results.append([s2ms(item.timestamp), item.id, histogram_data])
return results
......
......@@ -138,7 +138,7 @@ class LogWriter(object):
"""
if '%' in tag:
raise RuntimeError("% can't appear in tag!")
walltime = round(time.time()) if walltime is None else walltime
walltime = round(time.time() * 1000) if walltime is None else walltime
self._get_file_writer().add_record(
meta_data(tag=tag, display_name=display_name, step=step,
walltime=walltime))
......@@ -159,7 +159,7 @@ class LogWriter(object):
"""
if '%' in tag:
raise RuntimeError("% can't appear in tag!")
walltime = round(time.time()) if walltime is None else walltime
walltime = round(time.time() * 1000) if walltime is None else walltime
self._get_file_writer().add_record(
scalar(tag=tag, value=value, step=step, walltime=walltime))
......@@ -182,7 +182,7 @@ class LogWriter(object):
"""
if '%' in tag:
raise RuntimeError("% can't appear in tag!")
walltime = round(time.time()) if walltime is None else walltime
walltime = round(time.time() * 1000) if walltime is None else walltime
self._get_file_writer().add_record(
image(tag=tag, image_array=img, step=step, walltime=walltime))
......@@ -207,7 +207,7 @@ class LogWriter(object):
labels = ["label_1", "label_2", "label_3", "label_4", "label_5"]
writer.add_embedding(labels=labels, vectors=hot_vectors,
walltime=round(time.time()))
walltime=round(time.time() * 1000))
"""
if '%' in tag:
raise RuntimeError("% can't appear in tag!")
......@@ -216,7 +216,7 @@ class LogWriter(object):
if isinstance(labels, np.ndarray):
labels = labels.tolist()
step = 0
walltime = round(time.time()) if walltime is None else walltime
walltime = round(time.time() * 1000) if walltime is None else walltime
self._get_file_writer().add_record(
embedding(
tag=tag,
......@@ -260,7 +260,7 @@ class LogWriter(object):
"""
if '%' in tag:
raise RuntimeError("% can't appear in tag!")
walltime = round(time.time()) if walltime is None else walltime
walltime = round(time.time() * 1000) if walltime is None else walltime
if isinstance(audio_array, list):
audio_array = np.array(audio_array)
self._get_file_writer().add_record(
......@@ -297,7 +297,7 @@ class LogWriter(object):
if '%' in tag:
raise RuntimeError("% can't appear in tag!")
hist, bin_edges = np.histogram(values, bins=buckets)
walltime = round(time.time()) if walltime is None else walltime
walltime = round(time.time() * 1000) if walltime is None else walltime
self._get_file_writer().add_record(
histogram(
tag=tag,
......@@ -338,7 +338,7 @@ class LogWriter(object):
"""
if '%' in tag:
raise RuntimeError("% can't appear in tag!")
walltime = round(time.time()) if walltime is None else walltime
walltime = round(time.time() * 1000) if walltime is None else walltime
self._get_file_writer().add_record(
pr_curve(
tag=tag,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册