1 Error description
1.1 System Environment
Hardware Environment(Ascend/GPU/CPU): Ascend
Software Environment:
– MindSpore version (source or binary): 1.8.0
– Python version (eg, Python 3.7.5): 3.7.6
– OS platform and distribution (eg, Linux Ubuntu 16.04): Ubuntu 4.15.0-74-generic
– GCC/Compiler version (if compiled from source):
1.2 Basic information
1.2.1 Script
The training script is to perform a two-dimensional average pooling operation on the input multi-dimensional data by constructing a single-operator network of AvgPool. The script is as follows:
01 class Net(nn.Cell):
02 def __init__(self):
03 super(Net, self).__init__()
04 self.avgpool_op = ops.AvgPool(pad_mode="VALID", kernel_size=32, strides=1)
05
06 def construct(self, x):
07 result = self.avgpool_op(x)
08 return result
09
10 x = Tensor(np.arange(128 * 20 * 32 * 65).reshape(65, 32, 20, 128),mindspore.float32)
11 net = Net()
12 output = net(x)
13 print(output)
1.2.2 Error reporting
The error message here is as follows:
Traceback (most recent call last):
File "avgpool.py", line 17, in <module>
output = net(x)
File "/root/archiconda3/envs/lilinjie_high/lib/python3.7/site-packages/mindspore/nn/cell.py", line 573, in __call__
out = self.compile_and_run(*args)
File "/root/archiconda3/envs/lilinjie_high/lib/python3.7/site-packages/mindspore/nn/cell.py", line 956, in compile_and_run
self.compile(*inputs)
File "/root/archiconda3/envs/lilinjie_high/lib/python3.7/site-packages/mindspore/nn/cell.py", line 929, in compile
_cell_graph_executor.compile(self, *inputs, phase=self.phase, auto_parallel_mode=self._auto_parallel_mode)
File "/root/archiconda3/envs/lilinjie_high/lib/python3.7/site-packages/mindspore/common/api.py", line 1063, in compile
result = self._graph_executor.compile(obj, args_list, phase, self._use_vm_mode())
File "/root/archiconda3/envs/lilinjie_high/lib/python3.7/site-packages/mindspore/ops/primitive.py", line 575, in __infer__
out[track] = fn(*(x[track] for x in args))
File "/root/archiconda3/envs/lilinjie_high/lib/python3.7/site-packages/mindspore/ops/operations/nn_ops.py", line 1572, in infer_shape
raise ValueError(f"For '{self.name}', the each element of the output shape must be larger than 0, "
ValueError: For 'AvgPool', the each element of the output shape must be larger than 0, but got output shape: [65, 32, -3, 105]. The input shape: [65, 32, 20, 128], kernel size: (1, 1, 24, 24), strides: (1, 1, 1, 1).Please check the official api documents for more information about the output.
2 Solutions
For the reasons known above, it is easy to make the following modifications:
01 class Net(nn.Cell):
02 def __init__(self):
03 super(Net, self).__init__()
04 self.avgpool_op = ops.AvgPool(pad_mode="VALID", kernel_size=15, strides=1)
05
06 def construct(self, x):
07 result = self.avgpool_op(x)
08 return result
09
10 x = Tensor(np.arange(128 * 20 * 32 * 65).reshape(65, 32, 20, 128),mindspore.float32)
11 net = Net()
12 output = net(x)
13 print(output)
At this point, the execution is successful, and the output is as follows:
(65, 32, 6, 114)
3 Summary
Steps to locate the error report:
1. Find the line of user code that reports the error: output = net(x) ;
2. According to the keywords in the log error message, narrow the scope of the analysis problem* the each element of the output shape must be larger than 0* ;
3. It is necessary to focus on the correctness of variable definition and initialization.
Read More:
- [Solved] MindSpore Error: For primitive[TensorSummary], the v rank Must be greater than or equal to 0
- [Solved] MindSpore Error: For ‘MirrorPad‘, paddings must be a Tensor with *
- [Solved] MindSpore Error: ValueError: `padding_idx` in `Embedding` out of range
- [Solved] MindSpore Error: ValueError: Minimum inputs size 0 does not match…
- [Solved] MindSpore Error: TypeError: For ‘TopK’, the type of ‘x’ should be…
- [Solved] MindSpore Error: task_fail_info or current_graph_ is nullptr
- ValueError: Negative dimension size caused by subtracting 2 from 1 for…
- [Solved] MindSpore Error: Data type conversion of ‘Parameter’ is not supporte
- [Solved] MindSpore Error: “ValueError:invalid literal for int()with base10’the’
- [Solved] MindSpore Error: ReduceMean in the Ascend environment does not support inputs of 8 or more dimensions
- [Solved] MindSpore Error: For ‘CellList’, each cell should be subclass of Cell
- [Solved] MindSpore Error: StridedSlice operator does not support input of uint8 data type on Ascend hardware
- [Solved] TFrecords Create Datas Error: Number of int64 values != expected. Values size: 1 but output shape: [3]
- [Solved] MindSpore Error: Select GPU kernel op * fail! Incompatible data type
- [Solved] MindSpore Network custom reverse error: TypeError: The params of function ‘bprop’ of
- [Solved] MindSpore Error: `half_pixel_centers`=True only support in Ascend
- [Solved] MindSpore Error: “RuntimeError: Invalid data, Page size.”
- [Solved] MindSpore infer error when passing in sens values for derivation: For ‘MatMul’, the input dimensions
- [Solved] MindSpore Error: “TypeError: parse() missing 1 required positional.”