完整错误展示
UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=VGG16_Weights.IMAGENET1K_V1`. You can also use `weights=VGG16_Weights.DEFAULT` to get the most up-to-date weights.
warnings.warn(msg)
我的原始代码如下
import torchvision
from torchvision.models import VGG16_Weights
vgg16_false = torchvision.models.vgg16(weights=None)
vgg16_true = torchvision.models.vgg16(weights=VGG16_Weights)
warning的意思是weights=VGG16_Weights已经被弃用了,需要使用`weights=VGG16_Weights.IMAGENET1K_V1`来代替,或者使用`weights=VGG16_Weights.DEFAULT`来获取最新的权重
这个例子是学习B站我是土堆的视频里面的pytorch基础的第25讲,pretrained已经不用了。