1.如何加载pytorch中,torchvision预定义的模型的前几层
https://www.cnblogs.com/dyclown/p/13170884.html
https://www.cnblogs.com/jiangkejie/p/12952174.html
新定义一个class:
class myvgg(nn.Module):
def __init__(self):
super(myvgg,self).__init__()
vgg_pretrained=models.vgg(pretrained=True)
self.features=vgg_pretrained.features[:27]
def forward(self,x):
out=self.features(x)
return out