Closed zhjikoshlizhzc closed 5 years ago
Before I install cuda9.0,there is no error,but after I install cuda,this error occured.
File "
File "C:\Users\acer\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 704, in runfile execfile(filename, namespace)
File "C:\Users\acer\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/Graduate/DeepFool-master/DeepFool-master/Python/test_deepfool.py", line 60, in
File "C:\Users\acer\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py", line 60, in call img = t(img)
File "C:\Users\acer\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py", line 163, in call return F.normalize(tensor, self.mean, self.std, self.inplace)
File "C:\Users\acer\Anaconda3\lib\site-packages\torchvision\transforms\functional.py", line 207, in normalize std = torch.tensor(std, dtype=torch.float32)
TypeError: must be real number, not map
<Figure size 432x288 with 0 Axes>
I use python 3.7. Pytorch 0.4.1. After "map" in line 62 , std and mean are map not list, you need to transfer it into list. Original code: tf = transforms.Compose([transforms.Normalize(mean=[0, 0, 0],std=map(lambda x: 1 / x, std)), transforms.Normalize(mean=map(lambda x: -x, mean), std=[1, 1, 1]), transforms.Lambda(clip), transforms.ToPILImage(), transforms.CenterCrop(224)]) Change into: tf = transforms.Compose([transforms.Normalize(mean=[0, 0, 0], std=list(map(lambda x: 1 / x, std))), transforms.Normalize(mean=list(map(lambda x: -x, mean)), std=[1, 1, 1]), transforms.Lambda(clip), transforms.ToPILImage(), transforms.CenterCrop(224)])
Thanks a lot,this error is completed fixed!Thanks !
File "C:\Users\acer\Anaconda3\lib\site-packages\torchvision\transforms\functional.py", line 207, in normalize std = torch.tensor(std, dtype=torch.float32)
TypeError: must be real number, not map
<Figure size 432x288 with 0 Axes>