一文带你用可视化理解卷积神经网络(23)
让我们看看如何在VGG16模型的不同层获得输出:
#importing required libraries and functions
from keras.models import Model
#defining names of layers from which we will take the output
layer_names = ['block1_conv1''block2_conv1''block3_conv1''block4_conv2'
outputs = [
image = image.reshape((1 image.shape[0
image.shape[1
image.shape[2
))
#extracting the output and appending to outputs
for layer_name in layer_names:
intermediate_layer_model = Model(inputs=model.inputoutputs=model.get_layer(layer_name).output)
intermediate_output = intermediate_layer_model.predict(image)
outputs.append(intermediate_output)
#plotting the outputs
figax = plt.subplots(nrows=4ncols=5figsize=(2020))
for i in range(4):
for z in range(5):
ax[i
[z
.imshow(outputs[i
[0::z
)
ax[i
[z
.set_title(layer_names[i
)
ax[i
[z
.set_xticks([
)
ax[i
[z
.set_yticks([
)
推荐阅读
- 法术|双城之战:羁绊、海克斯强化、装备一文看懂
- 剑魂|DNF:“剑魂式打桩”引玩家爆笑,别人用瞬斩塞蛋,你用里鬼剑术
- 仙剑奇侠传七|“吃鸡”游戏中单价最高的氪金物品!氪度力压车皮,却一文不值!
- 地下城与勇士|DNF:DNF超高质量减负,9.14减负改动一文看完
- 金泰相|“亚军不配找借口”Doinb谈亚军一文不值,只有S11夺冠才能找回颜面
- 梦幻西游|梦幻西游:老王打错灵犀玉损失5000元,百万无级别变得一文不值
- 电子竞技|电竞精神一文不值,贝克曼惨遭炮轰,久城透露QG假赛隐情!
- 地下城与勇士|DNF:最尴尬的“神话守门员”,你用我推荐,给我我不要
- 声控|声控大法知多少?《神武4》电脑版的声控技巧你用过几个?
- 孙一文|王者荣耀孙一文联动实锤?采访透露设计想法,皮肤想要带龙标