‘numpy.ndarray‘ object has no attribute ‘cuda‘

问题描述:

Traceback (most recent call last):
File “D:/python/modelsmy/trainvgg16.py”, line 93, in
theta = deepfool(image, net)
File “D:\python\modelsmy\deepfool.py”, line 13, in deepfool
image = image.cuda()
AttributeError: ‘numpy.ndarray’ object has no attribute ‘cuda’

解决方案:
将image (原numpy类型) 转化成tensor 类型
image = torch.tensor(image)

你可能感兴趣的:(‘numpy.ndarray‘ object has no attribute ‘cuda‘)