深度学习:AttributeError: module ‘torchvision.transforms‘ has no attribute ‘Scale‘

 transform = transforms.Compose([
                transforms.Scale(32),
                transforms.ToTensor(),
                transforms.Normalize((0.5, 0.5, 0.5,), (0.5, 0.5, 0.5,))]
        )

报错:AttributeError: module 'torchvision.transforms' has no attribute 'Scale'

原因:

torchvision.transforms.Scale没有找到,因为它已被弃用,所以改为使用torchvision.transforms.Resize.

 transform = transforms.Compose([
                transforms.Resize(32),
                transforms.ToTensor(),
                transforms.Normalize((0.5, 0.5, 0.5,), (0.5, 0.5, 0.5,))]
        )

 

你可能感兴趣的:(实战深度学习常见问题汇总,深度学习,人工智能,pytorch,机器学习,python)