mindspore.ops.ScalarSummary

View Source On Gitee
class mindspore.ops.ScalarSummary[source]

This operator will put a scalar to a summary file with protocol buffer format. It must be used with mindspore.SummaryRecord or mindspore.SummaryCollector, which specify the directory of the summary file. The summary file can be loaded and shown by MindInsight, see MindInsight documents for details.

Inputs:
  • name (str) - The name of the input variable, it must not be an empty string.

  • value (Tensor) - The value of scalar, and the dim of value must be 0 or 1.

Raises
Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import mindspore.nn as nn
>>> import mindspore.ops as ops
>>> from mindspore import Tensor, set_context
>>>
>>>
>>> class SummaryDemo(nn.Cell):
...     def __init__(self,):
...         super(SummaryDemo, self).__init__()
...         self.summary = ops.ScalarSummary()
...         self.add = ops.Add()
...
...     def construct(self, x, y):
...         name = "x"
...         self.summary(name, x)
...         x = self.add(x, y)
...         return x
>>> set_context(mode=mindspore.GRAPH_MODE)
>>> summary = SummaryDemo()(Tensor(3), Tensor(4))
>>> print(summary)
7