Pytorch抽取网络层的Feature Map(Vgg)实例

作者:seeney 时间:2021-10-20 11:46:46 

这边我是需要得到图片在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

来源:https://blog.csdn.net/Mr_try/article/details/91044066

标签:Pytorch,抽取,网络层,Feature,Map,Vgg
0
投稿

猜你喜欢

  • 你知道怎么在淘宝里进行投诉吗?

    2008-06-04 12:00:00
  • CSS模块化设计

    2009-01-05 12:10:00
  • python读取ini配置文件过程示范

    2023-07-02 01:18:36
  • python读取和保存图片5种方法对比

    2022-05-27 23:54:32
  • 纠结于ajax开发中 response的contentType 问题

    2008-12-11 13:46:00
  • python保存字典和读取字典的实例代码

    2023-05-12 14:17:54
  • Gregarius中文日期格式问题解决办法

    2023-11-18 09:51:00
  • 快速认识CSS中的overflow属性

    2009-05-29 16:36:00
  • 关于 MediaPlayer 播放器参数详解

    2008-08-10 18:33:00
  • matplotlib中legend位置调整解析

    2023-07-17 03:00:44
  • python爬虫入门教程--HTML文本的解析库BeautifulSoup(四)

    2023-08-12 23:45:10
  • 交互设计杂七杂八

    2010-09-25 18:41:00
  • pytorch torchvision.ImageFolder的用法介绍

    2023-05-29 17:20:49
  • Python+PyQt5实现开发Memcached客户端

    2022-04-13 13:17:48
  • Python利用Selenium实现弹出框的处理

    2021-11-12 23:21:50
  • tensorflow: variable的值与variable.read_value()的值区别详解

    2023-01-02 22:29:40
  • Python中字典的setdefault()方法教程

    2021-11-18 08:59:00
  • 基于Swoole实现PHP与websocket聊天室

    2023-11-03 19:04:05
  • Python实现把回车符\\r\\n转换成\\n

    2022-09-21 07:22:14
  • oracle & mysql 多实例启动区别

    2011-02-23 12:28:00
  • asp之家 网络编程 m.aspxhome.com