李宏毅机器学习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

相关推荐
Tangyuewei几秒前
给 AI 套上缰绳:Harness Engineering 是什么
人工智能
AI棒棒牛5 分钟前
第11讲 | 目标检测任务:边界框、IoU、类别与置信度
人工智能·yolo·目标检测·yolo26
allione8 分钟前
AI时代测试方向AI for Testing和Testing for AI
人工智能·ai测试
武子康11 分钟前
GPT-Red:自动化红队如何形成 Agent 安全数据飞轮(4 个闭环 + 6 类评测指标 + 5 类风险误读)
人工智能·openai·agent
阿里云大数据AI技术12 分钟前
DataWorks Data Agent 实战课堂(二):一句话搞定数据集成+处理,实现端到端数据流水线
人工智能·agent
Days205013 分钟前
AI漫剧vs传统动漫vs真人短剧
人工智能
武子康15 分钟前
从恶意 Dataset 到横向移动:一套可落地的 Dataset Processing Threat Model(资产边界 + 威胁枚举 + 5 层控制)
人工智能·安全
redreamSo18 分钟前
一天涨 1800 星的 GitHub 榜首:AI 编程瓶颈变成了 token
人工智能·开源·github
wp123_123 分钟前
实测数据对飙:COILCRAFT XFL4020-222MEC vs TONEVEE MVL4020-2R2M,2.2µH功率电感参数全解读
人工智能
本末倒置18327 分钟前
从 PDF 到向量检索:一个最简单的本地 RAG 入库案例
人工智能