mindspore.ops.TensorSummary
- class mindspore.ops.TensorSummary[source]
This operator will put a tensor to a summary file with protocol buffer format. It must be used with SummaryRecord or 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.
value (Tensor) - The value of tensor, and the rank of tensor must be greater than 0.
- Raises
TypeError – If name is not a str.
TypeError – If value is not a Tensor.
ValueError – If rank of value is 0.
- 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.TensorSummary() ... self.add = ops.Add() ... ... def construct(self, x, y): ... x = self.add(x, y) ... name = "x" ... self.summary(name, x) ... return x >>> set_context(mode=mindspore.GRAPH_MODE) >>> summary = SummaryDemo()(Tensor([[1]]), Tensor([[2]])) >>> print(summary) [[3]]