模型调用方法求助
Created by: chenlizhi-1013
class Encoder(nn.Module): """ Encoder. """
def __init__(self, encoded_image_size=14):
super(Encoder, self).__init__()
self.enc_image_size = encoded_image_size
resnet = torchvision.models.resnet101(pretrained=True) # pretrained ImageNet ResNet-101
# Remove linear and pool layers (since we're not doing classification)
modules = list(resnet.children())[:-2]
self.resnet = nn.Sequential(*modules)
# Resize image to fixed size to allow input images of variable size
self.adaptive_pool = nn.AdaptiveAvgPool2d((encoded_image_size, encoded_image_size))
上面是用pytorch调用的模型,对模型进行更改,把最后两层去掉。老师,我现在想把这段代码用paddle框架实现,该如何写呢,我找不到方向。对于paddle的预训练模型,能不能访问每一层呢,请老师们帮忙解答一下。