mindspore.parse_print
- mindspore.parse_print(print_file_name)[source]
Parse data file generated by mindspore.ops.Print.
- Parameters
print_file_name (str) – The file name needs to be parsed.
- Returns
List, element of list is Tensor.
- Raises
ValueError – The print file does not exist or is empty.
RuntimeError – Failed to parse the file.
Examples
>>> import numpy as np >>> import mindspore as ms >>> import mindspore.ops as ops >>> from mindspore import nn >>> from mindspore import Tensor >>> 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) >>> >>> import mindspore >>> data = mindspore.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]])]