当前位置: 代码迷 >> 综合 >> pytorch mxnet ValueError: too many dimensions ‘NDArray‘
  详细解决方案

pytorch mxnet ValueError: too many dimensions ‘NDArray‘

热度:11   发布时间:2023-12-15 16:08:18.0

报错:

Traceback (most recent call last):File "topFAR_COX_py2_fc1_pytorch_PY3.py", line 199, in <module>IDimage_features_dict = getfeatures_dict(model, IDimage_list, IDimage_path, featurelen)File "topFAR_COX_py2_fc1_pytorch_PY3.py", line 106, in getfeatures_dictemb = extractfeature(model, oriimg)File "/home/user1/miniconda3/envs/py377/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_contextreturn func(*args, **kwargs)File "topFAR_COX_py2_fc1_pytorch_PY3.py", line 60, in extractfeatureimg = torch.Tensor(img).cuda()
ValueError: too many dimensions 'NDArray'

解决:

img = torch.Tensor(img.asnumpy()).cuda()
  相关解决方案