原文:
www.kdnuggets.com/2018/06/inside-mind-neural-network-interactive-code-tensorflow.html/2
alpha 值为 1.0
现在让我们使用 内部梯度,alpha 值为 ….
0.01, 0.01, 0.03, 0.04, 0.1, 0.5, 0.6, 0.7, 0.8 和 1.0(与原始输入相同),以可视化网络的内部工作。
上述所有图像表示了不同 alpha 值下相对于输入的梯度。我们可以观察到,随着 alpha 值的增加,梯度变得越来越接近 0(黑色),这是由于网络的饱和。我们可以清楚地看到,当我们将所有图像以 gif 格式查看时,梯度变化的差异。
然而,我能够做出一个有趣的观察,随着 alpha 值变小,我的网络无法做出正确的预测。如下面所示,当 alpha 值较小时(0.01),网络预测大多为 3 或 4(猫/鹿)
红色框 → 模型预测
但随着 alpha 值的增加,最终达到 1.0,我们可以观察到模型的准确性增加。最后,让我们查看每个 alpha 值下梯度的正面和负面属性。
蓝色像素 → 与原始图像叠加的正面属性
红色像素 → 与原始图像叠加的负面属性
再次,如果我们将这些图像制作成 gif,就更容易查看变化。
左侧图像 → 积分梯度,步长为 3000,用于 黎曼近似
右侧图像 → 正面属性用蓝色标记,负面属性用红色标记
最后,当我们使用积分梯度来可视化梯度时,我们可以观察到如上所示的结果。我发现的一个非常有趣的事实是网络如何预测马(7)、狗(5)和鹿(4)。
首先,让我们看一下原始图像,如上所示,左侧和中间的图像是马,右侧的图像是绵羊。
当我们可视化积分梯度时,可以看到一些有趣的现象。正如中间图像所示,网络认为马的头部最重要。然而,当仅仅考虑头部时,网络认为这是一张狗的图片。(而且它确实有点像狗)。右侧图像也有类似的故事,当网络仅考虑绵羊的头部时,它预测为狗。
然而,正如最左侧的图像所示,当网络接收马的整体形状(包括一些人类的部分)时,它正确地识别了这张图像为马。真是惊人!
对于 Google Colab,你需要一个谷歌账户来查看代码,另外你不能在 Google Colab 中运行只读脚本,所以请在你的沙盒中复制一份。最后,我永远不会请求访问你 Google Drive 上的文件,仅供参考。祝编程愉快!为了透明度,我已将所有训练日志上传到我的 GitHub。
要访问此帖子的代码,请 点击这里,要查看训练 日志请点击这里。
由于这一领域仍在发展中,将会有新的方法和发现。(我希望我也能为这些发现做出贡献。)最后,如果你想访问原始论文“Axiomatic Attribution for Deep Networks”的代码, 请点击这里。
如果发现任何错误,请发邮件到 jae.duk.seo@gmail.com。如果你希望查看我所有写作的列表,请 点击这里查看我的网站。
同时在我的 Twitter 关注我,访问 我的网站,或者我的 YouTube 频道 以获取更多内容。我还实现了 Wide Residual Networks,请点击这里查看博客文章。
参考资料
-
Axiom/definition/theorem/proof
。 (2018)。YouTube。检索于 2018 年 6 月 14 日,来自www.youtube.com/watch?v=OeC5WuZbNMI
-
axiom — 词典定义。(2018)。Vocabulary.com。检索于 2018 年 6 月 14 日,来自
www.vocabulary.com/dictionary/axiom
-
Axiomatic Attribution for Deep Networks — — Mukund Sundararajan, Ankur Taly, Qiqi Yan. (2017). Vimeo. 取自
vimeo.com/238242575
-
STL-10 数据集。 (2018). Cs.stanford.edu. 取自
cs.stanford.edu/~acoates/stl10/
-
Benenson, R. (2018). 分类数据集结果。 Rodrigob.github.io. 取自
rodrigob.github.io/are_we_there_yet/build/classification_datasets_results.html#53544c2d3130
-
[duplicate], H. (2018). 如何在 Matplotlib (python) 中隐藏坐标轴和网格线。 Stack Overflow. 取自
stackoverflow.com/questions/45148704/how-to-hide-axes-and-gridlines-in-matplotlib-python
-
VanderPlas, J. (2018). 多个子图 | Python 数据科学手册。 Jakevdp.github.io. 取自
jakevdp.github.io/PythonDataScienceHandbook/04.08-multiple-subplots.html
-
matplotlib.pyplot.subplot — Matplotlib 2.2.2 文档。 (2018). Matplotlib.org. 取自
matplotlib.org/api/_as_gen/matplotlib.pyplot.subplot.html
-
matplotlib, m. (2018). matplotlib 中超过 9 个子图。 Stack Overflow. 取自
stackoverflow.com/questions/4158367/more-than-9-subplots-in-matplotlib
-
pylab_examples 示例代码:subplots_demo.py — Matplotlib 2.0.0 文档。 (2018). Matplotlib.org. 取自
matplotlib.org/2.0.0/examples/pylab_examples/subplots_demo.html
-
matplotlib.pyplot.hist — Matplotlib 2.2.2 文档。 (2018). Matplotlib.org. 取自
matplotlib.org/api/_as_gen/matplotlib.pyplot.hist.html
-
Python?, I. (2018). 是否有一种干净的方法在 Python 中生成折线直方图? Stack Overflow. 取自
stackoverflow.com/questions/27872723/is-there-a-clean-way-to-generate-a-line-histogram-chart-in-python
-
Pyplot Text — Matplotlib 2.2.2 文档。 (2018). Matplotlib.org. 取自
matplotlib.org/gallery/pyplots/pyplot_text.html#sphx-glr-gallery-pyplots-pyplot-text-py
-
[ Google / ICLR 2017 / 论文总结 ] 反事实的梯度。 (2018). Towards Data Science. 于 2018 年 6 月 16 日访问,来自
towardsdatascience.com/google-iclr-2017-paper-summary-gradients-of-counterfactuals-6306510935f2
-
numpy.transpose — NumPy v1.14 手册。 (2018). Docs.scipy.org. 于 2018 年 6 月 16 日访问,来自
docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.transpose.html
-
命令,G。 (2018). 在一个命令中执行 git add 和 commit。 Stack Overflow. 于 2018 年 6 月 16 日访问,来自
stackoverflow.com/questions/4298960/git-add-and-commit-in-one-command
-
如何将图像切分为红色、绿色和蓝色通道。 (2018). 如何使用 misc.imread 将图像切分为红色、绿色和蓝色通道。 Stack Overflow. 于 2018 年 6 月 16 日访问,来自
stackoverflow.com/questions/37431599/how-to-slice-an-image-into-red-green-and-blue-channels-with-misc-imread
-
如何在 Windows 10 上安装 Bash shell 命令行工具。 (2016). Windows Central. 于 2018 年 6 月 16 日访问,来自
www.windowscentral.com/how-install-bash-shell-command-line-windows-10
-
Google Colab 免费 GPU 教程 — Deep Learning Turkey — Medium. (2018). Medium. 于 2018 年 6 月 16 日访问,来自
medium.com/deep-learning-turkey/google-colab-free-gpu-tutorial-e113627b9f5d
-
安装 — imgaug 0.2.5 文档。 (2018). Imgaug.readthedocs.io. 于 2018 年 6 月 16 日访问,来自
imgaug.readthedocs.io/en/latest/source/installation.html
-
numpy.absolute — NumPy v1.14 手册。 (2018). Docs.scipy.org. 于 2018 年 6 月 16 日访问,来自
docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.absolute.html
-
numpy.clip — NumPy v1.10 手册。 (2018). Docs.scipy.org. 于 2018 年 6 月 16 日访问,来自
docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.clip.html
-
numpy.percentile — NumPy v1.14 手册。 (2018). Docs.scipy.org. 于 2018 年 6 月 16 日访问,来自
docs.scipy.org/doc/numpy/reference/generated/numpy.percentile.html
-
CIFAR-10 和 CIFAR-100 数据集。 (2018). Cs.toronto.edu. 于 2018 年 6 月 16 日访问,来自
www.cs.toronto.edu/~kriz/cifar.html
-
[ICLR 2015] 追求简单性:具有交互式代码的全卷积网络 [手册…. (2018). Towards Data Science. 取自
towardsdatascience.com/iclr-2015-striving-for-simplicity-the-all-convolutional-net-with-interactive-code-manual-b4976e206760
于 2018 年 6 月 16 日 -
EN10/CIFAR. (2018). GitHub. 取自
github.com/EN10/CIFAR
于 2018 年 6 月 16 日 -
深度网络的公理归因 — — Mukund Sundararajan, Ankur Taly, Qiqi Yan. (2017). Vimeo. 取自
vimeo.com/238242575
于 2018 年 6 月 16 日 -
(2018). Arxiv.org. 取自
arxiv.org/pdf/1506.06579.pdf
于 2018 年 6 月 16 日 -
Riemann 和. (2018). En.wikipedia.org. 取自
en.wikipedia.org/wiki/Riemann_sum
于 2018 年 6 月 16 日
简介: Jae Duk Seo 是瑞尔森大学的四年级计算机科学学生。
原文。经授权转载。
相关:
-
用 NumPy 从头开始构建卷积神经网络
-
我如何使用 CNN 和 TensorFlow 并在 Kaggle 挑战中失去了银牌
-
使用 TensorFlow 对象检测进行像素级分类
1. 谷歌网络安全证书 - 快速进入网络安全职业生涯。
2. 谷歌数据分析专业证书 - 提升你的数据分析水平
3. 谷歌 IT 支持专业证书 - 支持你的组织在 IT 领域