标签:elf self children init def res war pre 模型
import torch.nn as nn
import torchvision.models as models
class resnet(nn.Module):
def __init__(self):
super(resnet,self).__init__()
self.model = models.resnet18(pretrained=True)
self.encoder = nn.Sequential(*list(self.model.children())[:-1])
def forward(self,x):
y = self.encoder(x)
return y
net = resnet()
标签:elf self children init def res war pre 模型
原文地址:https://www.cnblogs.com/dyclown/p/13170884.html