mindspore.parse_print

View Source On Gitee
mindspore.parse_print(print_file_name)[source]

Parse data file generated by mindspore.ops.Print.

Note

The interface is deprecated from version 2.5 and will be removed in a future version.

Parameters

print_file_name (str) – The file name needs to be parsed.

Returns

List, element of list is Tensor.

Raises

Examples

>>> import numpy as np
>>> import mindspore as ms
>>> from mindspore import nn, Tensor, ops
>>> ms.set_context(mode=ms.GRAPH_MODE, print_file_path='log.data')
>>> class PrintInputTensor(nn.Cell):
...         def __init__(self):
...             super().__init__()
...             self.print = ops.Print()
...
...         def construct(self, input_pra):
...             self.print('print:', input_pra)
...             return input_pra
>>> x = np.array([[1, 2, 3, 4], [5, 6, 7, 8]]).astype(np.float32)
>>> input_pra = Tensor(x)
>>> net = PrintInputTensor()
>>> net(input_pra)
>>>
>>> data = ms.parse_print('./log.data')
>>> print(data)
['print:', Tensor(shape=[2, 4], dtype=Float32, value=
[[ 1.00000000e+00,  2.00000000e+00,  3.00000000e+00,  4.00000000e+00],
[ 5.00000000e+00,  6.00000000e+00,  7.00000000e+00,  8.00000000e+00]])]