AttributeError: module ‘torchvision.transforms’ has no attribute ‘Scale’
背景:
在使用transforms模型对图像预处理时,发现transforms没有Scale这个属性,原来是新版本中已经删除了Scale这个属性,改成Resize了
原因分析:
主要是torchvision的版本不一样,新版本的torchvision中的transforms没有Scale属性,改成Resize就好。
解决方案:
Before:
transform = transforms.Compose([transforms.Scale([128, 128]),transforms.ToTensor()])
After:
transform = transforms.Compose([transforms.Resize([128, 128]),transforms.ToTensor()])