第十章 解读卷积神经网络的学习成果
Interpreting what ConvNets learn
运行代码
在 Colab 上运行
在 GitHub 上查看
本章内容
- 解释卷积神经网络如何分解输入图像
- 可视化卷积神经网络学习到的滤波器
- 可视化图像中负责特定分类决策的区域
- Interpreting how ConvNets decompose an input image
- Visualizing the filters learned by ConvNets
- Visualizing areas in an image responsible for a certain classification decision
构建计算机视觉应用时,一个根本性问题是可解释性:为什么分类器会认为某张图像中包含冰箱,而你看到的明明是一辆卡车?这在深度学习用于辅助人类专业知识的应用场景中尤为重要,例如医学影像应用。本章将介绍一系列不同的可视化卷积神经网络学习内容和理解其决策的技术。
人们常说深度学习模型是“黑箱”:它们学习到的表征难以提取并以人类可读的形式呈现。虽然这种说法对某些类型的深度学习模型部分正确,但对卷积神经网络(ConvNets)而言则完全不成立。卷积神经网络学习到的表征非常易于可视化,这很大程度上是因为它们是 对视觉概念的表征(representations of visual concepts)。自 2013 年以来,人们开发了多种可视化和解释这些表征的技术。我们不会一一介绍,但会重点介绍其中三种最易于理解和使用的方法:
- 可视化卷积神经网络的中间输出(中间激活值) ——有助于理解连续的卷积神经网络层如何转换其输入,并初步了解各个卷积神经网络滤波器的含义。
- 可视化卷积神经网络的滤波器——有助于精确理解卷积神经网络中每个滤波器所响应的视觉模式或概念。
- 可视化图像中类别激活的热图——有助于了解图像中哪些部分被识别为属于特定类别,从而帮助您定位图像中的对象。
- Visualizing intermediate ConvNet outputs (intermediate activations) — Useful for understanding how successive ConvNet layers transform their input, and for getting a first idea of the meaning of individual ConvNet filters
- Visualizing ConvNets filters — Useful for understanding precisely what visual pattern or concept each filter in a ConvNet is receptive to
- Visualizing heatmaps of class activation in an image — Useful for understanding which parts of an image were identified as belonging to a given class, thus allowing you to localize objects in images
对于第一种方法——激活可视化——你将使用你在第 8 章中从头开始训练的用于解决猫狗分类问题的小型卷积神经网络。对于接下来的两种方法,你将使用预训练的 Xception 模型。