Browse Source

Drop histogram steps if original_buckets_count is too large to avoid time consuming re-sample process.

tags/v0.3.0-alpha
liangyongxiong 5 years ago
parent
commit
fc72cac5ea
2 changed files with 22 additions and 8 deletions
  1. +9
    -0
      mindinsight/datavisual/data_transform/histogram_container.py
  2. +13
    -8
      mindinsight/datavisual/data_transform/ms_data_loader.py

+ 9
- 0
mindinsight/datavisual/data_transform/histogram_container.py View File

@@ -72,6 +72,10 @@ class Bucket:


class HistogramContainer:

# Max quantity of original buckets.
MAX_ORIGINAL_BUCKETS_COUNT = 90

"""
Histogram data container.

@@ -114,6 +118,11 @@ class HistogramContainer:
"""Gets original proto message."""
return self._msg

@property
def original_buckets_count(self):
"""Gets original buckets quantity."""
return len(self._original_buckets)

def set_visual_range(self, max_val: float, min_val: float, bins: int) -> None:
"""
Sets visual range for later re-sampling.


+ 13
- 8
mindinsight/datavisual/data_transform/ms_data_loader.py View File

@@ -239,14 +239,19 @@ class MSDataLoader:

if value.HasField('histogram'):
histogram_msg = HistogramContainer(value.histogram)
tag = '{}/{}'.format(value.tag, PluginNameEnum.HISTOGRAM.value)
tensor_event = TensorEvent(wall_time=event.wall_time,
step=event.step,
tag=tag,
plugin_name=PluginNameEnum.HISTOGRAM.value,
value=histogram_msg,
filename=self._latest_summary_filename)
self._events_data.add_tensor_event(tensor_event)
# Drop steps if original_buckets_count exceeds HistogramContainer.MAX_ORIGINAL_BUCKETS_COUNT
# to avoid time-consuming re-sample process.
if histogram_msg.original_buckets_count > HistogramContainer.MAX_ORIGINAL_BUCKETS_COUNT:
logger.warning('original_buckets_count exceeds HistogramContainer.MAX_ORIGINAL_BUCKETS_COUNT')
else:
tag = '{}/{}'.format(value.tag, PluginNameEnum.HISTOGRAM.value)
tensor_event = TensorEvent(wall_time=event.wall_time,
step=event.step,
tag=tag,
plugin_name=PluginNameEnum.HISTOGRAM.value,
value=histogram_msg,
filename=self._latest_summary_filename)
self._events_data.add_tensor_event(tensor_event)

if event.HasField('graph_def'):
graph_proto = event.graph_def


Loading…
Cancel
Save