一文带你用可视化理解卷积神经网络(13)
#creating a VGG16 model using fully connected layers also because then we can
#visualize the patterns for individual category
from keras.applications import VGG16
model = VGG16(weights='imagenet'include_top=True)
#finding out the layer index using layer name
#the find_layer_idx function accepts the model and name of layer as parameters and return the index of respective layer
layer_idx = utils.find_layer_idx(model'predictions')
#changing the activation of the layer to linear
model.layers[layer_idx
.activation = activations.linear
#applying modifications to the model
model = utils.apply_modifications(model)
#Indian elephant
img3 = visualize_activation(modellayer_idxfilter_indices=385max_iter=5000verbose=True)
plt.imshow(img3)
我们的模型使用随机输入对印度象进行分类 , 生成了以下输出:
从上面的图像中 , 我们可以观察到该模型需要像牙齿 , 大眼睛和象牙这样的结构 。 现在 , 这些信息对于我们检查数据集的完整性非常重要 。 因为印度象通常存在于长满树木或长草的栖息地中 , 所以模型可能会侧重于背景中的栖息地特征 , 而这是不对的 。
推荐阅读
- 法术|双城之战:羁绊、海克斯强化、装备一文看懂
- 剑魂|DNF:“剑魂式打桩”引玩家爆笑,别人用瞬斩塞蛋,你用里鬼剑术
- 仙剑奇侠传七|“吃鸡”游戏中单价最高的氪金物品!氪度力压车皮,却一文不值!
- 地下城与勇士|DNF:DNF超高质量减负,9.14减负改动一文看完
- 金泰相|“亚军不配找借口”Doinb谈亚军一文不值,只有S11夺冠才能找回颜面
- 梦幻西游|梦幻西游:老王打错灵犀玉损失5000元,百万无级别变得一文不值
- 电子竞技|电竞精神一文不值,贝克曼惨遭炮轰,久城透露QG假赛隐情!
- 地下城与勇士|DNF:最尴尬的“神话守门员”,你用我推荐,给我我不要
- 声控|声控大法知多少?《神武4》电脑版的声控技巧你用过几个?
- 孙一文|王者荣耀孙一文联动实锤?采访透露设计想法,皮肤想要带龙标