CNN神经网络猫狗分类经典案例,深度学习过程中间层激活特征图可视化(1)

深度学习过程中每一层的神经网络激活图。

def visible():

model = load_model(model_file_name)

layer_outputs = [layer.output for layer in model.layers[:8]]

activation_model = models.Model(inputs=model.input, outputs=layer_outputs)

img_path = ‘./data/test/cat/cat.4041.jpg’

img = image.load_img(img_path, target_size=(150, 150))

img_tensor = image.img_to_array(img)

img_tensor = img_tensor / 255

img_tensor = np.expand_dims(img_tensor, axis=0)

activations = activation_model.predict(img_tensor)

for k in range(len(activations)):

first_layer_activation = activations[k]

print(first_layer_activation.shape)

col = 8

plt.figure(figsize=(50, 50))

for i in range(first_layer_activation.shape[3]):

col列。

plt.subplot((first_layer_activation.shape[3] / col) + 1, col, i + 1)

  • 21
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值