解决ret = umr_sum(arr, axis, dtype, out, keepdims)RuntimeError: The size of tensor a (400) must match(
Posted 沉迷单车的追风少年
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决ret = umr_sum(arr, axis, dtype, out, keepdims)RuntimeError: The size of tensor a (400) must match(相关的知识,希望对你有一定的参考价值。
项目场景:
numpy np.mean()计算平均值
问题描述:
完整报错如下:
Traceback (most recent call last):
File "test_wq.py", line 88, in <module>
valid_cls(model, im_test_data, sk_test_data)
File "test_wq.py", line 54, in valid_cls
avg = np.mean(presicion_array)
File "<__array_function__ internals>", line 6, in mean
File "/root/anaconda3/envs/dpm-pc-gen/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 3373, in mean
out=out, **kwargs)
File "/root/anaconda3/envs/dpm-pc-gen/lib/python3.7/site-packages/numpy/core/_methods.py", line 160, in _mean
ret = umr_sum(arr, axis, dtype, out, keepdims)
RuntimeError: The size of tensor a (400) must match the size of tensor b (20) at non-singleton dimension 0
原因分析
以上是关于解决ret = umr_sum(arr, axis, dtype, out, keepdims)RuntimeError: The size of tensor a (400) must match(的主要内容,如果未能解决你的问题,请参考以下文章
numpy.array()是否等于numpy.stack(...,axis = 0)?