深度学习: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,))]
        )

猜你喜欢

转载自blog.csdn.net/weixin_44575717/article/details/125368309
今日推荐