李宏毅机器学习2022-HW9--Explainable AI

Task

CNN explanation

11种食物图片分类,与HW3使用同一个dataset

  • Bread, Diary product, Dessert, Egg, Fried food, Meat, Noodles/Pasta, Rice, Seafood, Soup, and Vegetables/Fruit

训练一个CNN model用于classification,并做一些explanations

Lime package

Lime

Saliency map

What is Saliency map ?

Saliency: 顯著性

The heatmaps that highlight pixels of the input image that contribute the most in the classification task.

Ref: https://medium.com/datadriveninvestor/visualizing-neural-networks-using-saliency-maps-in-pytorch-289d8e244ab4

We put an image into the model, forward then calculate the loss referring to the label. Therefore, the loss is related to:

  • image
  • model parameters
  • label

Generally speaking, we change model parameters to fit "image" and "label". When backward, we calculate the partial differential value of loss to model parameters. 一般来说,我们改变模型参数来拟合"图像"和"标签"。当反向时,我们计算损失对模型参数的偏微分值。

Now, we have another look. When we change the image's pixel value, the partial differential value of loss to image shows the change in the loss. We can say that it means the importance of the pixel. We can visualize it to demonstrate which part of the image contribute the most to the model's judgment. 现在,我们再看一遍。当我们改变图像的像素值时,损耗对图像的偏微分值表示损耗的变化。我们可以说这意味着像素的重要性。我们可以将其可视化,以演示图像的哪一部分对模型的判断贡献最大。

Smooth Grad

Smooth grad 的方法是,在圖片中隨機地加入 noise,然後得到不同的 heatmap,把這些 heatmap 平均起來就得到一個比較能抵抗 noisy gradient 的結果。

The method of Smooth grad is to randomly add noise to the image and get different heatmaps. The average of the heatmaps would be more robust to noisy gradient.

ref: https://arxiv.org/pdf/1706.03825.pdf

Filter Visualization

https://reurl.cc/mGZNbA

Integrated Gradients

https://arxiv.org/pdf/1703.01365.pdf

BERT Explanation

  • Attention Visualization
  • Embedding Visualization
  • Embedding analysis

##Attention Visualization

https://exbert.net/exBERT.html

##Embedding Visualization

Embedding 二维化

##Embedding analysis

用Euclidean distance 和 Cosine similarity 两种方法比较output embedding

下图是"果"

#Code Link

详细代码和问题解答见Github

相关推荐
Uncommon.11 小时前
使用Pytorch自动计算梯度
人工智能·pytorch·python
安逸sgr11 小时前
循环神经网络 RNN、LSTM、GRU 是什么?为什么能处理序列?
人工智能·ai·大模型·agent·智能体
猿小猴子11 小时前
主流 AGENT 实战教程「OpenCodex」与「ChatGPT Work」与「Codex Record & Replay」介绍
人工智能·ai·chatgpt·codex·minimax·deepseek·opencodex
shdwak....sad11 小时前
版本管理&迁移kali-vmware&知识库
人工智能·网络安全
程序员cxuan12 小时前
OpenAI Linux 版来了!
人工智能·后端·程序员
用户56190350693312 小时前
OpenAI兼容API报401/404/429怎么解决?API Key、Base URL、模型名排查
人工智能
lucky_syq12 小时前
专栏目录与学习路线 | 48 篇正文导览
人工智能·学习
TechEdu20260612 小时前
[人工智能]RLlib:基于Ray的可扩展强化学习框架
人工智能·ai
加多12 小时前
DeepSeek Harness 深度分析:用途、问题、架构原理与使用指南
人工智能·架构
风流 少年12 小时前
Spring AI 2.0:Flux
java·人工智能·spring