rahul003 commented on a change in pull request #9994: [MXNET-59] Tensorboard: 
Add histogram callback
URL: https://github.com/apache/incubator-mxnet/pull/9994#discussion_r189720574
 
 

 ##########
 File path: python/mxnet/contrib/tensorboard.py
 ##########
 @@ -71,3 +72,43 @@ def __call__(self, param):
             if self.prefix is not None:
                 name = '%s-%s' % (self.prefix, name)
             self.summary_writer.add_scalar(name, value)
+
+    def node_histogram_visualization(self, prefix=None, node_names=None, 
bins="auto"):
+        """Node histogram visualization in TensorBoard.
+        This callback works almost same as `callback.module_checkpoint`,
+        but write TensorBoard event file for visualization.
+        For more usage, please refer https://github.com/dmlc/tensorboard
+
+        Parameters
+        ----------
+        prefix : str
+            Prefix for a metric name of `histograms` and `distributions` value.
+        node_names : list of str, optional
+            Name of nodes list you want to visualize.
+            If set 'None', this callback visualize all nodes histogram and 
distributions.
+            Default node_names = None.
+        bins : str
+            one of {'tensorflow','auto', 'fd', ...}, this determines how the 
bins are made.
+            You can find other options in:
+            
https://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html
+            Default bins = 'auto'
+        """
+        self.histogram_prefix = prefix
+        self.node_names = node_names
+        self.bins = bins
+
+        # pylint: disable=unused-argument
+        def _callback(iter_no, sym=None, arg=None, aux=None):
+            """Callback to log node histogram visualization in TensorBoard."""
+            for k, v in arg.items():
+                if self.node_names is None or k in self.node_names:
+                    if self.histogram_prefix is not None:
+                        name = '%s-%s' % (self.histogram_prefix, k)
+                    self.summary_writer.add_histogram(name, v, 
global_step=iter_no, bins=self.bins)
+            for k, v in aux.items():
+                if self.node_names is None or k in self.node_names:
+                    if self.histogram_prefix is not None:
+                        name = '%s-%s' % (self.histogram_prefix, k)
+                    self.summary_writer.add_histogram(name, v, 
global_step=iter_no, bins=self.bins)
 
 Review comment:
   This PR is still helpful to use Symbolic mode with mxboard. I'm trying to 
use it, however this name is used without being initialized. In case someone 
else is using it, you need to make that change

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to