这边我是需要得到图片在Vgg的5个block里relu后的Feature Map (其余网络只需要替换就可以了)
索引可以这样获得
vgg = models.vgg19(pretrained=True).features.eval()
print (vgg)
Feature Map可利用下面的class
class Vgg16(nn.Module):
def __init__(self, pretrained=True):
super(Vgg16, self).__init__()
self.net = models.vgg16(pretrained).features.eval()
def forward(self, x):
out = []
for i in range(len(self.net)):
x = self.net[i](x)
if i in [3, 8, 15, 22, 29]:
# print(self.net[i])
out.append(x
return out
本文介绍了一种方法,用于从预训练的VGG19网络中获取特定层的ReLU激活特征图,通过定义一个Vgg16类并重写forward方法,实现了在VGG网络的5个关键block中提取特征。
&spm=1001.2101.3001.5002&articleId=91044066&d=1&t=3&u=6da361bfca65407c9c56dd5102e43f8b)

被折叠的 条评论
为什么被折叠?



