audio
audioduration (s)
998
4.31k
transcription
stringlengths
9.84k
43.3k
translation
stringlengths
16.1k
72.2k
file
stringlengths
11
12
上 次 我 們 還 沒 有 把 self-supervised learning 的 部 分 講 完 我 們 講 完 了 bert 那 除 了 bert 以 外 還 有 下 一 個 也 是 鼎 鼎 有 名 的 模 型 就 是 gpt 系 列 的 模 型 那 gpt 系 列 的 模 型 做 的 是 什 麼 呢 上 次 我 們 有 說 bert 做 的 是 什 麼 bert 做 的 是 填 空 題 gpt 做 的 事 情 是 什 麼 呢 gpt 就 是 改 一 下 我 們 現 在 在 self-supervised learning 的 時 候 要 模 型 做 的 任 務 gpt 要 做 的 任 務 是 預 測 接 下 來 會 出 現 的 token 是 什 麼 舉 例 來 說 假 設 你 的 訓 練 資 料 裡 面 有 一 個 句 子 是 台 灣 大 學 那 gpt 拿 到 這 一 筆 訓 練 資 料 的 時 候 它 會 做 什 麼 樣 的 訓 練 呢 它 做 的 事 情 是 這 樣 你 給 它 bos 這 個 token 然 後 呢 gpt output 一 個 embedded 然 後 接 下 來 呢 你 用 這 個 embedded 去 預 測 下 一 個 應 該 出 現 的 token 是 什 麼 呢 那 在 這 個 句 子 裡 面 根 據 這 筆 訓 練 資 料 下 一 個 應 該 出 現 的 token 是 什 麼 呢 下 一 個 應 該 出 現 的 token 是 台 所 以 你 要 訓 練 你 的 模 型 根 據 第 一 個 token 根 據 bos 給 你 的 embedded 那 它 要 輸 出 台 這 個 token 而 如 果 這 個 部 分 詳 細 來 看 就 是 這 樣 你 有 一 個 embedded 這 邊 用 h 來 表 示 然 後 通 過 一 個 linear transform 再 通 過 一 個 softmax 得 到 一 個 distribution 跟 一 般 你 做 分 類 的 問 題 是 一 樣 的 接 下 來 你 希 望 你 output 的 distribution 跟 正 確 答 案 的 cross entropy 越 小 越 好 也 就 是 你 要 去 預 測 下 一 個 出 現 的 token 是 什 麼 好 那 接 下 來 要 做 的 事 情 就 是 以 此 類 推 了 你 給 你 的 gpt bos 跟 台 它 產 生 embedded 接 下 來 它 會 預 測 下 一 個 出 現 的 token 是 什 麼 那 你 告 訴 它 說 下 一 個 應 該 出 現 的 token 是 灣 好 再 反 覆 繼 續 下 去 你 給 它 bos 台 跟 灣 然 後 預 測 下 一 個 應 該 出 現 的 token 它 應 該 要 預 測 大 你 給 它 台 跟 灣 跟 大 接 下 來 下 一 個 應 該 出 現 的 token 是 學 它 應 該 要 預 測 出 下 一 個 應 該 出 現 的 token 是 學 那 這 邊 呢 是 指 拿 一 筆 資 料 一 個 句 子 來 給 gpt 訓 練 當 然 實 際 上 你 不 會 只 用 一 筆 句 子 你 會 用 成 千 上 萬 個 句 子 來 訓 練 這 個 模 型 然 後 呢 就 沒 有 然 後 了 這 樣 就 這 樣 子 說 完 了 它 厲 害 的 地 方 就 是 用 了 很 多 資 料 訓 了 一 個 異 常 巨 大 的 模 型 然 後 看 看 它 會 有 什 麼 厲 害 的 地 方 那 這 邊 有 一 個 小 小 的 應 該 要 跟 大 家 說 的 地 方 是 說 這 個 gpt 的 模 型 它 像 是 一 個 transformer 的 decoder 我 們 知 道 transformer 有 encoder 有 decoder 對 不 對 這 我 們 上 課 的 時 候 都 有 講 過 模 型 呢 它 的 架 構 像 是 transformer 的 decoder 不 過 拿 掉 bos 的 tension 這 個 部 分 也 就 是 說 你 會 做 那 個 mask 的 tension 就 是 你 現 在 在 預 測 給 bos 預 測 台 的 時 候 你 不 會 看 到 接 下 來 出 現 的 詞 彙 給 它 台 要 預 測 灣 的 時 候 你 不 會 看 到 接 下 來 要 輸 入 的 詞 彙 以 此 類 推 這 個 就 是 gpt 那 這 個 gpt 最 知 名 的 就 是 因 為 gpt 可 以 預 測 下 一 個 token 那 所 以 它 有 生 成 的 能 力 你 可 以 讓 它 不 斷 地 預 測 下 一 個 token 產 生 完 整 的 文 章 所 以 我 每 次 提 到 gpt 的 時 候 它 的 形 象 都 是 一 隻 獨 角 獸 為 什 麼 它 的 形 象 是 一 隻 獨 角 獸 呢 因 為 gpt 系 列 最 知 名 的 一 個 例 子 就 是 用 gpt 寫 了 一 篇 跟 獨 角 獸 有 關 的 新 聞 因 為 他 放 一 個 假 新 聞 然 後 那 個 假 新 聞 裡 面 說 在 安 地 斯 山 脈 發 現 獨 角 獸 等 等 一 個 活 靈 活 現 的 假 新 聞 所 以 大 家 提 到 gpt 的 時 候 都 會 想 到 那 一 則 假 新 聞 好 為 了 讓 你 更 清 楚 了 解 gpt 運 作 起 來 是 什 麼 樣 子 那 這 個 線 上 有 一 個 demo 的 網 頁 叫 做 talk to transformer 就 是 有 人 把 一 個 比 較 小 的 不 是 那 個 最 大 的 gpt 的 模 型 最 大 的 gpt 模 型 不 是 public available 的 有 人 把 比 較 小 的 gpt 模 型 放 在 線 上 讓 你 可 以 輸 入 一 個 句 子 讓 它 會 把 接 下 來 的 其 餘 的 內 容 把 它 補 完 它 這 個 運 作 起 來 看 起 來 像 是 好 這 個 就 是 gpt 系 列 它 可 以 把 一 句 話 補 完 那 把 一 句 話 補 完 怎 麼 把 它 用 在 downstream 的 任 務 上 呢 舉 例 來 說 怎 麼 把 它 用 在 question answering 或 者 是 其 他 的 跟 人 類 語 言 處 理 有 關 的 任 務 上 呢 gpt 用 的 想 法 跟 bert 不 一 樣 其 實 我 要 強 調 一 下 gpt 也 可 以 跟 bert 用 一 樣 的 做 法 大 家 還 記 得 bert 是 怎 麼 做 的 嗎 把 bert model 拿 出 來 後 面 接 一 個 簡 單 的 linear 的 classifier 那 你 就 可 以 做 很 多 事 情 你 也 可 以 把 gpt 拿 出 來 接 一 個 簡 單 的 classifier 我 相 信 也 是 會 有 效 但 是 在 gpt 的 論 文 中 它 沒 有 這 樣 做 它 有 一 個 更 狂 的 想 法 為 什 麼 會 有 更 狂 的 想 法 呢 因 為 首 先 就 是 bert 那 一 招 bert 用 過 了 嘛 所 以 總 不 能 再 用 一 樣 的 東 西 這 樣 寫 paper 就 沒 有 人 覺 得 厲 害 了 然 後 再 來 就 是 gpt 這 個 模 型 也 許 真 的 太 大 了 大 到 連 fine tune 可 能 都 有 困 難 你 想 想 看 我 們 在 用 bert 的 時 候 你 要 把 bert 模 型 後 面 接 一 個 linear classifier 然 後 bert 也 是 你 的 要 train 的 model 的 一 部 分 所 以 它 的 參 數 也 是 要 調 的 所 以 在 剛 才 助 教 公 告 的 bert 相 關 的 作 業 裡 面 你 還 是 需 要 花 一 點 時 間 來 training 雖 然 助 教 說 你 大 概 20 分 鐘 就 可 以 train 完 了 因 為 你 並 不 是 要 train 一 個 完 整 的 bert 的 模 型 bert 的 模 型 在 之 前 在 做 這 個 填 空 題 的 時 候 已 經 訓 練 得 差 不 多 了 你 只 需 要 微 調 它 就 好 了 但 是 微 調 還 是 要 花 時 間 的 也 許 gpt 實 在 是 太 過 巨 大 巨 大 到 要 微 調 它 要 train 一 個 η 可 能 都 有 困 難 所 以 gpt 系 列 有 一 個 更 狂 的 使 用 方 式 這 個 更 狂 的 使 用 方 式 和 人 類 更 接 近 你 想 想 看 假 設 你 去 考 譬 如 說 托 福 的 聽 力 測 驗 你 是 怎 麼 去 考 托 福 的 聽 力 測 驗 的 呢 這 個 托 福 聽 力 測 驗 的 敘 述 是 長 什 麼 樣 子 的 呢 首 先 你 會 看 到 一 個 題 目 的 說 明 告 訴 你 說 現 在 要 考 選 擇 題 請 從 abcd 四 個 選 項 裡 面 選 出 正 確 的 答 案 等 等 然 後 給 你 一 個 範 例 告 訴 你 說 這 是 題 目 然 後 正 確 的 答 案 是 多 少 然 後 你 看 到 新 的 問 題 期 待 你 就 可 以 舉 一 反 三 開 始 作 答 gpt 系 列 要 做 的 事 情 就 是 這 個 模 型 能 不 能 夠 做 一 樣 的 事 情 呢 舉 例 來 說 假 設 要 gpt 這 個 模 型 做 翻 譯 你 就 先 打 translate english to french 就 先 給 它 這 個 句 子 這 個 句 子 代 表 問 題 的 描 述 然 後 給 它 幾 個 範 例 跟 它 說 sea otter 然 後 => 後 面 就 應 該 長 這 個 樣 子 或 者 是 這 個 什 麼 plush giraffe plush giraffe 後 面 就 應 該 長 這 個 樣 子 等 等 然 後 接 下 來 你 問 它 說 cheese=> 叫 它 把 後 面 的 補 完 希 望 它 就 可 以 產 生 翻 譯 的 結 果 不 知 道 大 家 能 不 能 夠 了 解 這 一 個 想 法 是 多 麼 地 狂 在 training 的 時 候 gpt 並 沒 有 教 它 做 翻 譯 這 件 事 它 唯 一 學 到 的 就 是 給 一 段 文 字 的 前 半 段 把 後 半 段 補 完 就 像 我 們 剛 才 給 大 家 示 範 的 例 子 一 樣 現 在 我 們 直 接 給 它 前 半 段 的 文 字 就 長 這 個 樣 子 告 訴 它 說 你 要 做 翻 譯 了 給 你 幾 個 例 子 告 訴 你 說 翻 譯 是 怎 麼 回 事 接 下 來 給 它 cheese 這 個 英 文 單 字 後 面 能 不 能 就 直 接 接 出 法 文 的 翻 譯 結 果 呢 這 個 在 gpt 的 文 獻 裡 面 叫 做 few-shot learning 但 是 它 跟 一 般 的 few-shot learning 又 不 一 樣 所 謂 few shot 的 意 思 是 說 確 實 只 給 了 它 一 點 例 子 所 以 叫 做 few shot 但 是 它 不 是 一 般 的 learning 這 裡 面 完 全 沒 有 什 麼 gradient descent training 的 時 候 就 是 要 跑 gradient descent 嘛 這 邊 完 全 沒 有 gradient descent 完 全 沒 有 要 去 調 gpt 那 個 模 型 參 數 的 意 思 所 以 在 gpt 的 文 獻 裡 面 把 這 種 訓 練 給 了 一 個 特 殊 的 名 字 它 們 叫 做 in-context learning 代 表 說 它 不 是 一 種 一 般 的 learning 它 連 gradient descent 都 沒 有 做 當 然 你 也 可 以 給 gpt 更 大 的 挑 戰 我 們 在 考 托 福 聽 力 測 驗 的 時 候 都 只 給 一 個 例 子 而 已 那 gpt 可 不 可 以 只 看 一 個 例 子 就 知 道 它 要 做 翻 譯 這 件 事 這 個 叫 one-shot learning 還 有 更 狂 的 是 zero-shot learning 直 接 給 它 一 個 敘 述 說 我 們 現 在 要 做 翻 譯 了 gpt 能 不 能 夠 自 己 就 看 得 懂 就 自 動 知 道 說 要 來 做 翻 譯 這 件 事 情 呢 那 如 果 能 夠 做 到 的 話 那 真 的 就 非 常 地 驚 人 了 那 gpt 系 列 到 底 有 沒 有 達 成 這 個 目 標 呢 這 個 是 一 個 見 仁 見 智 的 問 題 啦 它 不 是 完 全 不 可 能 答 對 但 是 正 確 率 有 點 低 相 較 於 你 可 以 微 調 模 型 正 確 率 是 有 點 低 的 那 細 節 你 就 再 看 看 gpt 那 篇 文 章 第 三 代 的 gpt 它 測 試 了 42 個 任 務 這 個 縱 軸 是 正 確 率 這 些 實 線 這 三 條 實 線 是 42 個 任 務 的 平 均 正 確 率 那 這 邊 包 括 了 few shot one shot 跟 zero shot 三 條 線 分 別 代 表 few shot one shot 跟 zero shot 橫 軸 代 表 模 型 的 大 小 它 們 測 試 了 一 系 列 不 同 大 小 的 模 型 從 只 有 0.1 個 billion 的 參 數 到 175 個 billion 的 參 數 那 從 0.1 個 billion 的 參 數 到 175 個 billion 的 參 數 我 們 看 few shot learning 的 部 分 從 20 幾 % 的 正 確 率 平 均 正 確 率 一 直 做 到 50 幾 % 的 平 均 正 確 率 那 至 於 50 幾 % 的 平 均 正 確 率 算 是 有 做 起 來 還 是 沒 有 做 起 來 那 這 個 就 是 見 仁 見 智 的 問 題 啦 目 前 看 起 來 狀 況 是 有 些 任 務 它 還 真 的 學 會 了 舉 例 來 說 2 這 個 加 減 法 你 給 它 一 個 數 字 加 另 外 一 個 數 字 它 真 的 可 以 得 到 正 確 的 兩 個 數 字 加 起 來 的 結 果 但 是 有 些 任 務 它 可 能 怎 麼 學 都 學 不 會 譬 如 說 一 些 跟 邏 輯 推 理 有 關 的 任 務 它 的 結 果 就 非 常 非 常 地 慘 好 那 有 關 gpt3 的 細 節 這 個 就 留 給 大 家 再 自 己 研 究 然 後 這 邊 有 一 個 過 去 上 課 的 錄 影 我 把 連 結 放 在 這 邊 給 大 家 參 考 好 剛 才 舉 的 例 子 到 目 前 為 止 我 們 舉 的 例 子 都 是 只 有 跟 文 字 有 關 但 是 你 不 要 誤 會 說 這 種 self-supervised learning 的 概 念 只 能 用 在 文 字 上 在 語 音 在 cv cv 就 是 computer vision 也 就 是 影 像 在 語 音 跟 影 像 的 應 用 上 也 都 可 以 用 self-supervised learning 的 技 術 那 其 實 今 天 self-supervised learning 的 技 術 非 常 非 常 地 多 我 們 講 的 bert 跟 gpt 系 列 它 只 是 三 個 類 型 的 這 個 self-supervised learning 的 方 法 的 其 中 一 種 它 們 是 屬 於 prediction 那 一 類 那 其 實 還 有 其 他 的 類 型 那 就 不 是 我 們 這 一 堂 課 要 講 的 那 接 下 來 的 課 程 你 可 能 會 覺 得 有 點 流 水 帳 就 是 我 們 每 一 個 主 題 呢 就 是 告 訴 你 說 這 個 主 題 裡 面 有 什 麼 但 是 細 節 這 個 更 多 的 知 識 就 留 給 大 家 自 己 來 做 更 進 一 步 的 研 究 所 以 這 些 投 影 片 只 是 要 告 訴 你 說 在 self-supervised learning 這 個 部 分 我 們 講 的 只 是 整 個 領 域 的 其 中 一 小 塊 那 還 有 更 多 的 內 容 是 等 待 大 家 去 探 索 的 好 那 有 關 影 像 的 部 分 呢 我 們 就 真 的 不 會 細 講 我 這 邊 就 是 放 兩 頁 投 影 片 帶 過 去 告 訴 你 說 有 一 招 非 常 有 名 的 叫 做 simclr 它 的 概 念 也 不 難 我 相 信 你 自 己 讀 論 文 應 該 也 有 辦 法 看 懂 它 那 還 有 很 奇 怪 的 叫 做 byol byol 這 個 東 西 呢 我 們 是 不 太 可 能 在 上 課 講 它 為 什 麼 呢 因 為 根 本 不 知 道 它 為 什 麼 會 work 不 是 這 個 是 很 新 的 論 文 這 個 是 去 年 夏 天 的 論 文 那 這 個 論 文 是 假 設 它 不 是 已 經 發 表 的 文 章 然 後 學 生 來 跟 我 提 這 個 想 法 我 一 定 就 是 我 一 定 不 會 讓 他 做 這 不 可 能 會 work 的 這 是 個 不 可 能 會 實 現 的 想 法 不 可 能 會 成 功 的 這 個 想 法 感 覺 有 一 個 巨 大 的 瑕 疵 但 不 知 道 為 什 麼 它 是 work 的 而 且 還 曾 經 一 度 得 到 state of the art 的 結 果 deep learning 就 是 這 麼 神 奇 好 所 以 這 個 呢 我 們 也 就 不 細 講 就 跳 過 去 好 那 在 語 音 的 部 分 你 也 完 全 可 以 使 用 self-supervised learning 的 概 念 你 完 全 可 以 試 著 訓 練 語 音 版 的 bert 那 怎 麼 訓 練 語 音 版 的 bert 呢 你 就 看 看 文 字 版 的 bert 是 怎 麼 訓 練 的 譬 如 說 做 填 空 題 語 音 也 可 以 做 填 空 題 就 把 一 段 聲 音 訊 號 蓋 起 來 叫 機 器 去 猜 蓋 起 來 的 部 分 是 什 麼 嘛 語 音 也 可 以 預 測 接 下 來 會 出 現 的 內 容 講 gpt 就 是 預 測 接 下 來 要 出 現 的 token 嘛 那 語 音 你 也 可 以 叫 它 預 測 叫 模 型 預 測 接 下 來 會 出 現 的 聲 音 訊 號 所 以 你 也 可 以 做 語 音 版 的 gpt 不 管 是 語 音 版 的 bert 語 音 版 的 gpt 其 實 都 已 經 有 很 多 相 關 的 研 究 成 果 了 不 過 其 實 在 語 音 上 相 較 於 文 字 處 理 的 領 域 還 是 有 一 些 比 較 缺 乏 的 東 西 那 我 認 為 現 在 很 缺 乏 的 一 個 東 西 就 是 像 glue 這 樣 子 的 benchmark corpus 在 自 然 語 言 處 理 的 領 域 在 文 字 上 有 glue 這 個 corpus 我 們 在 這 門 課 的 剛 開 頭 這 個 投 影 片 的 剛 開 頭 就 告 訴 你 說 有 一 個 這 個 基 準 的 資 料 庫 叫 做 glue 它 裡 面 有 九 個 nlp 的 任 務 今 天 你 要 知 道 bert 做 得 好 不 好 就 讓 它 去 跑 那 九 個 任 務 在 去 平 均 那 代 表 這 個 self-supervised learning 模 型 的 好 壞 但 在 語 音 上 到 目 前 為 止 還 沒 有 類 似 的 基 準 的 資 料 庫 所 以 我 們 實 驗 室 就 跟 其 他 的 研 究 團 隊 共 同 開 發 了 一 個 語 音 版 的 glue 我 們 叫 做 superb 它 是 speech processing universal performance benchmark 的 縮 寫 你 知 道 今 天 你 做 什 麼 模 型 都 一 定 要 硬 湊 梗 才 行 啦 所 以 這 邊 也 是 要 硬 湊 一 個 梗 把 它 叫 做 superb 那 其 實 我 們 已 經 準 備 了 差 不 多 了 其 實 網 站 都 已 經 做 好 了 只 等 其 他 團 隊 的 人 看 過 以 後 就 可 以 上 線 了 所 以 現 在 雖 然 還 沒 有 上 線 但 是 再 過 一 陣 子 你 應 該 就 可 以 找 得 到 相 關 的 連 結 在 這 個 基 準 語 料 庫 裡 面 包 含 了 十 個 不 同 的 任 務 那 語 音 其 實 有 非 常 多 不 同 的 面 向 很 多 人 講 到 語 音 相 關 的 技 術 都 只 知 道 語 音 辨 識 把 聲 音 轉 成 文 字 但 這 並 不 是 語 音 技 術 的 全 貌 語 音 其 實 包 含 了 非 常 豐 富 的 資 訊 它 除 了 有 內 容 的 資 訊 就 是 你 說 了 什 麼 還 有 其 他 的 資 訊 舉 例 來 說 這 句 話 是 誰 說 的 舉 例 這 個 人 說 這 句 話 的 時 候 他 的 語 氣 是 什 麼 樣 還 有 這 句 話 背 後 它 到 底 有 什 麼 樣 的 語 意 所 以 我 們 準 備 了 十 個 不 同 的 任 務 這 個 任 務 包 含 了 語 音 不 同 的 面 向 包 括 去 檢 測 一 個 模 型 它 能 夠 識 別 內 容 的 能 力 識 別 誰 在 說 話 的 能 力 識 別 他 是 怎 麼 說 的 能 力 甚 至 是 識 別 這 句 話 背 後 語 意 的 能 力 從 全 方 位 來 檢 測 一 個 self-supervised learning 的 模 型 它 在 理 解 人 類 語 言 上 的 能 力 而 且 我 們 還 有 一 個 toolkit 這 個 toolkit 裡 面 就 包 含 了 各 式 各 樣 的 self-supervised learning 的 模 型 還 有 這 些 self-supervised learning 的 模 型 它 可 以 做 的 各 式 各 樣 語 音 的 下 游 的 任 務 然 後 把 連 結 放 在 這 邊 給 大 家 參 考 講 這 些 只 是 想 告 訴 大 家 說 self-supervised learning 的 技 術 不 是 只 能 被 用 在 文 字 上 在 這 個 影 像 上 在 語 音 上 都 仍 然 有 非 常 大 的 空 間 可 以 使 用 self-supervised learning 的 技 術 好 那 這 個 self-supervised learning 的 部 分 呢 這 個 bert 跟 gpt 我 們 就 講 到 這 邊
Last time we did not finish self-supervised learning part yet We finished discussing BERT Apart from BERT There is another one which is also a very famous model that is the GPT series model What does the GPT series model do We talked about this last time What BERT does BERT is for filling in the blanks What does GPT do? GPT is to modify what we are doing now In the self-supervised learning process The task assigned to the model The task for GPT is Predicting what comes next What kind of token will appear For example Assuming in your training data There is a sentence saying 'Taiwan University' Then when GPT receives this piece of training data What sort of training will it undertake What it does is like this You give it the BOS token And then GPT produces an embedded output. And what happens next? You use this embedded output to predict the next one. What should be the next token to appear? In this sentence, Based on this training data, What should be the next token to appear? The next token that should appear is Tai. So, you need to train your model. Based on the first token According to the embedded given by BOS Then it needs to output this token If we look at this part To go into details, it's like this You have an embedded Here it is represented by h And then it passes through a Linear Transform Followed by a softmax Obtain a distribution It's the same as the general classification problem you deal with Next You hope that the distribution you output And the cross entropy of the correct answer The smaller the better That is, you want to predict What the next appearing token is Alright, the next thing to do is The same logic applies here You provide your GPT With the BOS and the model It generates embedded Then it predicts What the next appearing token is And you tell it The token that should appear next Is 'Bay' Alright, keep repeating the process You feed it BOS, Taiwan, and Bay Then predict the next token that should appear It should predict 'Big' You feed it 'Taiwan', 'Bay' and 'Big' Next The next token that should appear is 'Learn' It should predict The next token that should appear is 'Learn' And what about this side? It's about using one piece of data, one sentence To train GPT Of course, in reality, you wouldn't use just one sentence You would use thousands and thousands of sentences To train this model And then, well, there's no then, that's it So that's the end of that The thing that's powerful about it is I used a lot of data And trained an exceptionally large model Then let's see what impressive aspects it has Here is a little thing That I should mention to everyone It's about this GPT model It is like a transformer's decoder We know the transformer has an encoder And a decoder, right? We have discussed this in our class As for the model Its structure is like the decoder of the transformer But it removes the tension part of the BOS In other words You will perform that mask tension You are predicting for BOS now When predicting the platform You won't see the words that appear next When it is tasked with predicting Taiwan, You won't see the words to be entered next, And so on, this is GPT, The most well-known of which is the GPT, Because GPT can predict the next token, So it has generative capabilities, You can keep it predicting the next token, To generate a complete article, So every time I mention GPT, Its image is a unicorn Why is its image a unicorn? Because one of the most famous examples of the GPT series Is using GPT to write an article About a unicorn-related news Because he posted a fake news And in that fake news it says Unicorns were found in the Andes mountains, etc. A very realistic fake news So when people mention GPT They will think of that fake news Alright, to help you understand better What it's like when GPT works There is a demo webpage online It's called 'Talk to Transformer' Someone has made a smaller Not the biggest GPT model The biggest GPT model It's not publicly available Someone put a smaller GPT model online So you can input a sentence It will fill in the remaining content Complete it This is how it works It looks like Okay, this is the GPT series It can complete a sentence Finish that sentence How to apply it to downstream tasks? For example How to use it in question answering Or other tasks Related to human language processing? The idea that GPT uses is different from BERT I must emphasize that GPT can also use the same method as BERT Does everyone still remember how BERT was implemented? Take out the BERT model Add a simple linear classifier to it Then you can do many things You can also take out GPT Attach a simple classifier I believe it would also be effective But in the GPT paper They didn't do it this way It has an even crazier idea Why would there be a crazier idea? Because, first of all, BERT has used that BERT technique, right? So, we can't keep using the same thing Otherwise, no one would think the paper is impressive Then, the next is The GPT model Maybe it's really too big It's so complex that even fine-tuning could be difficult Think about it, when we use BERT You have to connect a BERT model With a linear classifier at the end And BERT is also a part of The model you need to train So its parameters also need to be adjusted So as mentioned in the assistant's recent announcement Concerning the BERT-related homework You still need to spend some time training Although the teaching assistant says it's probably 20 minutes And then it can be trained. Because you are not training one The full model of BERT The BERT model knew beforehand When doing this fill in the blank test It's almost trained You only need to fine-tune it But finetuning still takes time Perhaps GPT is simply too huge So large it needs to be fine-tuned You need to train an η There might be difficulties So, the GPT series There's an even crazier way to use it This even crazier way to use it Closer to humans Think about it, if you were to take a test Such as the TOEFL listening test How do you approach it Like the TOEFL listening test This is a narrative of the TOEFL listening test What does it look like? First, you will see the instructions for the problem Telling you that now you have to choose multiple choice questions Please choose from the four options, ABCD Choosing the correct answer, etc. Then, I'll give you an example Let me tell you, this is the topic And what is the correct answer And then you come across a new problem You're expected to infer from one example and start answering What the GPT series is supposed to do is Can this model Do the same thing For example, if you want the GPT model to do translation You firstly type 'Translate English to French' First, give it this sentence This sentence represents the description of the problem Then give it a few examples and tell it And then there's the sea otter It should look like this at the back Or this something called plush giraffe Behind the plush giraffe It should look like this, and so on And then You ask it 'cheese' => Call it to complete the rest We hope it will generate the translated results I'm not sure if everyone can understand How crazy this idea is, During the training GPT wasn't taught translation The only thing it has learned is Given the first half of a text Completing the second half Just like the example we just demonstrated for everyone Now we provide it directly with the first half of the text This is what it looks like Tell it that you are going to translate Giving you a few examples Let me explain how translation works Next, give it the English word cheese, Can it be directly connected afterwards? What about the translation result in French? This is in the GPT literature It's called Few-shot Learning But it's different from common Few-shot Learning They are different What Few Shot means is Indeed, only few examples were given to it So it is called Few Shot But it's not ordinary learning There is nothing in it Gradient descent During the training It's about running gradient descent, There's no gradient descent here at all No tuning was done at all The meaning of the parameters in the GPT model So, in the documentation of GPT This training has been given a special name They call it In-context Learning This means that it is not a kind of General learning It hasn't even performed a gradient descent Of course, you can also give GPT a bigger challenge When we're taking the TOEFL listening test They all just give one example Can GPT only look at one example? That it needs to do translation This is called One-shot Learning There's even more crazy stuff It's Zero-shot Learning Give a statement directly We are going to do the translation now. Can GPT understand on its own it automatically knows that it needs to do this translation thing, If that can be achieved, That would be truly amazing The GPT series Did we achieve this goal or not? It's a subjective matter It's not completely impossible to get it right But the accuracy is a bit low Compared to you can fine-tune the model The accuracy rate is a bit low For details, please refer to the GPT paper The third generation of GPT It tested 42 tasks The vertical axis is accuracy rate These solid lines, these three solid lines It's the average accuracy rate of 42 tasks This includes Few Shot One Shot and Zero Shot The three lines respectively represent Few Shot One Shot and Zero Shot The x-axis represents the size of the model. They tested a series of models of different sizes Starting from just 0.1 billion parameters up to 175 billion parameters Then from 0.1 billion parameters To 175 billion parameters We look at the part of Few Shot learning From approximately 20% accuracy, the average accuracy Managed to maintain an average accuracy rate of over 50% As for the average accuracy rate of over 50% Does it perform, or does it not This is indeed a matter of different opinions Currently, it seems like It did learn some tasks For example, this addition and subtraction You take one number and add it to another It can really achieve it The correct result of adding two numbers But there are some tasks It might never learn no matter how hard it tries Like tasks related to logical reasoning Its results are very, very poor Alright, about the details of GPT3 I will leave this for everyone to research on their own. And here's a recorded video from a past class I will leave the link here for everyone's reference. Ok, the example I just gave The examples we have given so far It's all related to text. But don't misunderstand me The concept of self-supervised learning. Can only be used on text In speech, in CV CV means Computer Vision That is, the image It can also be applied to audio and image The technique of self-supervised learning Actually, today techniques of self-supervised learning A whole lot, really a lot We're talking about the BERT and GPT series It's just one of the three types The method of self-supervised learning One type of They belong to the prediction category Actually, there are other types This is not what we are going to discuss in this lesson Then, the upcoming lessons You might find it a bit monotonous It's our each topic It's about telling inside this topic What's there, but the details require further knowledge. Leave it to everyone to do further research So these slides I just want to tell you In the area of self-supervised learning. What we're discussing is just a small part of the whole field But there's more content It's waiting for everyone to explore Okay, what about the part about images? We really won't go into detail All I did was send over two slides Let me tell you, there is a very famous trick Called SimCLR The concept is not difficult I believe you read the paper yourself You should also be able to understand it And there are strange ones It's called BYOL This thing called BYOL It’s unlikely we will go into this during the lecture. Why is that? Because we have no idea why it would work No, this is a very new paper This was a paper from last summer So, this paper is about Assuming it's not an already published article Then a student came up with this idea I must be I will definitely not let him do it This can't possibly work This is an idea that's impossible to implement It's impossible to succeed This idea seems to have a huge flaw But I don't know why it works And it has once achieved State-of-the-art results Deep learning is so incredible Okay, so this is So we won't go into details and skip it Okay, for the part about language You can also completely use it The concept of self-supervised learning You can certainly try to train The voice version of BERT So how to train a speech version of BERT? you could look into the text version of BERT. How it's trained Such as doing fill-in-the-blank exercises You can also fill in the blanks with audio It covers up a segment of sound signals Ask the machine to guess what the covered part is Speech can also predict the content that will appear next Speaking of GPT, it's about prediction The token that will appear next Then you can also ask it to predict speech Predict the sound signals that will appear next with the model So you can also create a voice version of GPT No matter it's the speech version of BERT The voice version of GPT In fact, there have already been many related research achievements. But actually, in terms of voice Compared to the field of text processing There are still some things that are rather lacking I think what is missing right now is It's just like GLUE Benchmark corpus In the field of natural language processing There is a GLUE corpus in text At the beginning of this course The beginning of this slide Let me tell you there's one This benchmark database is called GLUE It contains nine NLP tasks Today, you need to know if BERT is performing well Let it run those nine tasks and then average them It represents self-supervised learning The good and bad of the model But so far in speech There is no similar benchmark database yet So our lab is just like other research teams Co-developed a voice version of GLUE We call it SUPERB It is Speech processing Universal The abbreviation of Performance Benchmark Do you know what model you're working on today Always need to forcefully make puns So here is also to force a joke Call it SUPERB We have pretty much prepared In fact, the website has already been built Just waiting for other team members to review it It can go online So even though it's not online yet But after a while You should be able to find the relevant links, In this benchmark corpus Including ten different tasks Voice actually has many different aspects Many people talk about speech-related technology They only recognize turning voice into text But this isn't the full picture of speech technology Speech actually contains a lot of rich information, Apart from the information of the content, Whatever you said And other information For instance, who said this sentence Take, for example, when this person says this sentence What's his tone like? There's also the meaning behind this sentence What kind of semantics does it possess So we have prepared ten different tasks This task includes different aspects of voice This includes testing a model. It has the ability to recognize content The ability to identify who is speaking The ability to discern how he says it Or even the ability to understand the meaning behind this sentence That examines from all angles models of self-supervised learning Its ability to understand human language And we also have a Toolkit This Toolkit contains A variety of A model of self-supervised learning And these The model of self-supervised learning What it can do The downstream task of all kinds of speech And put the link here for everyone to refer to All these are just to tell you The technique of self-supervised learning Not just applicable to text In this image, in speech There is still a lot of room to be utilized. The technique of self-supervised learning Okay, this one Regarding the part of self-supervised learning That will be all for BERT and GPT
week10_1.wav
好 那 個 接 下 來 我 們 要 講 auto-encoder 那 auto-encoder 我 們 可 能 先 講 一 小 段 以 後 我 們 就 下 課 休 息 一 下 然 後 我 再 把 auto-encoder 的 部 分 補 完 然 後 等 一 下 助 教 就 會 講 跟 auto-encoder 有 關 的 作 業 好 那 我 們 來 講 auto-encoder 那 在 講 auto-encoder 之 前 其 實 auto-encoder 也 可 以 算 是 self-supervised learning 的 一 環 所 以 再 讓 我 們 用 非 常 短 的 時 間 來 看 一 下 self-supervised learning 的 framework 那 self-supervised learning 是 怎 麼 運 作 的 首 先 你 有 大 量 的 沒 有 標 註 的 資 料 用 這 些 沒 有 標 註 的 資 料 你 可 以 去 訓 練 一 個 模 型 你 必 須 發 明 一 些 不 需 要 標 註 資 料 的 任 務 比 如 說 做 填 空 題 比 如 說 預 測 下 一 個 token 你 必 須 要 自 己 想 一 些 不 需 要 標 註 資 料 的 任 務 給 你 的 模 型 進 行 學 習 那 這 個 不 用 標 註 資 料 的 學 習 叫 做 self-supervised learning 或 者 是 也 有 人 叫 pre-training 那 用 這 些 不 用 標 註 資 料 的 任 務 學 完 一 個 模 型 以 後 它 本 身 沒 有 什 麼 用 bert 只 能 做 填 空 題 gpt 只 能 夠 把 一 句 話 補 完 但 是 你 可 以 把 它 用 在 其 他 下 游 的 任 務 裡 面 你 可 以 把 self-supervised learning 的 model 做 一 點 點 的 微 微 的 調 整 就 可 以 用 在 下 游 的 任 務 裡 面 那 在 這 些 self-supervised learning 的 任 務 裡 面 在 這 些 不 用 標 註 資 料 就 可 以 學 習 的 任 務 裡 面 在 有 bert 在 有 gpt 之 前 其 實 有 一 個 更 古 老 的 任 務 更 古 老 的 不 需 要 用 標 註 資 料 的 任 務 就 叫 做 auto-encoder 所 以 你 也 可 以 把 auto-encoder 看 作 是 self-supervised learning 的 一 種 pre-train 的 方 法 當 然 可 能 不 是 所 有 人 都 會 同 意 這 個 觀 點 有 人 可 能 會 說 這 個 auto-encoder 不 算 是 self-supervised learning 這 個 auto-encoder 很 早 就 有 了 嘛 2006 年 15 年 前 就 有 了 嘛 然 後 self-supervised learning 是 19 年 才 有 這 個 詞 彙 嘛 所 以 auto-encoder 不 算 self-supervised learning 的 一 環 那 這 個 都 是 見 仁 見 智 的 問 題 這 種 名 詞 定 義 的 問 題 真 的 我 們 就 不 用 太 糾 結 在 這 個 地 方 從 self-supervised learning 它 是 不 需 要 用 label data 來 訓 練 這 個 觀 點 來 看 auto-encoder 我 認 為 它 可 以 算 是 self-supervised learning 的 其 中 的 一 種 方 法 它 就 跟 填 空 預 測 接 下 來 的 token 是 很 類 似 的 概 念 只 是 用 的 是 另 外 不 一 樣 的 想 法 好 那 接 下 來 我 們 就 來 先 看 一 下 auto-encoder 是 怎 麼 運 作 的 好 那 auto-encoder 是 怎 麼 運 作 的 呢 那 現 在 我 們 因 為 剛 才 在 講 self-supervised learning 的 時 候 都 是 用 文 字 做 例 子 那 現 在 我 們 換 成 用 影 像 來 做 例 子 假 設 你 有 非 常 大 量 的 圖 片 在 auto-encoder 裡 面 你 有 兩 個 network 一 個 叫 做 encoder 一 個 叫 做 decoder 他 們 就 是 兩 個 network 這 兩 個 network 做 的 事 情 是 什 麼 這 兩 個 network 做 的 事 情 是 encoder 把 一 張 圖 片 讀 進 來 它 把 這 張 圖 片 變 成 一 個 向 量 就 encoder 它 可 能 是 很 多 層 的 cnn 把 一 張 圖 片 讀 進 來 它 的 輸 出 是 一 個 向 量 接 下 來 這 個 向 量 會 變 成 decoder 的 輸 入 decoder 會 產 生 一 張 圖 片 所 以 decoder 的 network 的 架 構 可 能 會 像 是 gan 裡 面 的 generator 它 是 11 個 向 量 輸 出 一 張 圖 片 不 管 是 encoder 還 是 decoder 反 正 就 是 多 層 的 network 那 現 在 訓 練 的 目 標 是 什 麼 訓 練 的 目 標 是 希 望 encoder 的 輸 入 跟 decoder 的 輸 出 越 接 近 越 好 假 設 你 把 圖 片 看 作 是 一 個 很 長 的 向 量 的 話 我 們 就 希 望 這 個 向 量 跟 decoder 的 輸 出 這 個 向 量 這 兩 個 向 量 他 們 的 距 離 越 接 近 越 好 也 有 人 把 這 件 事 情 叫 做 reconstruction 叫 做 重 建 因 為 我 們 就 是 把 一 張 圖 片 壓 縮 成 一 個 向 量 接 下 來 decoder 要 根 據 這 個 向 量 重 建 原 來 的 圖 片 那 我 們 希 望 原 輸 入 的 結 果 跟 重 建 後 的 結 果 越 接 近 越 好 講 到 這 邊 你 可 能 會 發 現 說 這 個 東 西 這 個 概 念 似 曾 相 似 沒 錯 我 們 在 講 cycle gan 的 時 候 已 經 講 過 了 這 個 概 念 對 不 對 我 們 說 在 做 cycle gan 的 時 候 我 們 會 需 要 兩 個 generator 第 一 個 generator 把 x domain 的 圖 片 轉 到 y domain 另 外 一 個 generator 把 y domain 的 圖 片 轉 回 來 希 望 最 原 先 的 圖 片 跟 轉 完 兩 次 後 的 圖 片 越 接 近 越 好 那 這 邊 encoder 和 decoder 這 個 auto-encoder 的 概 念 跟 cycle gan 其 實 是 一 模 一 樣 的 都 是 希 望 所 有 的 圖 片 經 過 兩 次 轉 換 以 後 要 跟 原 來 的 輸 出 越 接 近 越 好 而 這 個 訓 練 的 過 程 完 全 不 需 要 任 何 的 標 註 資 料 你 只 需 要 蒐 集 到 大 量 的 圖 片 你 就 可 以 做 這 個 訓 練 所 以 它 是 一 個 unsupervised learning 的 方 法 跟 self-supervised 那 一 系 列 pre-training 的 做 法 一 樣 你 完 全 不 需 要 任 何 的 標 註 資 料 那 像 這 樣 子 這 個 encoder 的 輸 出 有 時 候 我 們 叫 它 embedding 我 們 在 講 bert 的 時 候 也 提 過 embedding 這 個 詞 彙 了 那 有 的 人 叫 它 representation 有 的 人 叫 它 code 因 為 encoder 是 一 個 編 碼 嘛 所 以 這 個 有 人 把 這 個 vector 叫 做 code 那 其 實 指 的 都 是 同 一 件 事 情 好 那 這 個 auto-encoder 的 技 術 要 怎 麼 用 呢 怎 麼 把 train 的 auto-encoder 用 在 downstream 的 任 務 裡 面 呢 常 見 的 用 法 就 是 原 來 的 圖 片 你 也 可 以 把 它 看 作 是 一 個 很 長 的 向 量 但 這 個 向 量 太 長 了 不 好 處 理 那 怎 麼 辦 呢 你 把 這 個 圖 片 丟 到 encoder 以 後 輸 出 另 外 一 個 向 量 這 個 向 量 你 會 讓 它 比 較 短 比 如 說 只 有 10 維 只 有 100 維 那 你 拿 這 個 新 的 向 量 來 做 你 接 下 來 的 任 務 也 就 是 圖 片 不 再 是 一 個 很 高 維 度 的 向 量 它 通 過 encoder 的 壓 縮 以 後 變 成 了 一 個 低 維 度 的 向 量 你 再 拿 這 個 低 維 度 的 向 量 來 做 接 下 來 想 做 的 事 情 這 就 是 常 見 的 auto-encoder 用 在 downstream 的 任 務 用 在 下 游 任 務 的 方 法 那 因 為 通 常 encoder 的 輸 入 是 一 個 維 度 非 常 高 的 向 量 而 encoder 的 輸 出 也 就 是 我 們 的 embedding representation 或 者 code 它 是 一 個 非 常 低 維 度 的 向 量 比 如 說 輸 入 是 100×100 的 圖 片 那 100×100 那 就 是 1 萬 維 的 向 量 了 如 果 是 rgb 那 就 是 3 萬 維 的 向 量 但 是 通 常 encoder 的 output 你 會 設 得 很 小 比 如 說 10 100 這 樣 的 等 級 所 以 這 個 這 邊 會 有 一 個 特 別 窄 的 地 方 所 以 這 個 部 分 這 個 encoder 的 輸 出 有 時 候 又 叫 做 bottleneck 叫 做 瓶 頸 就 本 來 輸 入 是 很 寬 的 輸 出 也 是 很 寬 的 中 間 特 別 窄 所 以 這 一 段 就 叫 做 bottleneck 而 encoder 做 的 事 情 是 把 本 來 很 高 維 度 的 東 西 轉 成 低 維 度 的 東 西 把 高 維 度 的 東 西 轉 成 低 維 度 的 東 西 又 叫 做 dimension 的 reduction dimension reduction 這 個 技 術 我 相 信 你 在 machine learning 相 關 的 應 用 上 應 該 常 常 聽 到 這 個 名 詞 那 有 關 dimension reduction 的 技 術 它 其 實 牽 涉 的 非 常 非 常 地 廣 所 以 我 們 這 邊 就 不 再 細 講 因 為 這 門 課 我 們 只 專 注 在 深 度 學 習 相 關 的 技 術 你 可 以 把 auto-encoder 的 encoder 當 作 拿 來 做 dimension reduction 那 其 他 還 有 很 多 不 是 deep learning base 的 不 是 以 深 度 學 習 為 基 礎 的 dimension reduction 的 技 術 我 就 把 錄 影 的 連 接 留 在 這 邊 比 如 說 pca 比 如 說 t-sne 我 就 把 錄 影 的 連 結 留 在 這 邊 給 大 家 參 考 好 那 auto-encoder 到 底 好 在 哪 裡 當 我 們 把 一 個 高 維 度 的 圖 片 變 成 一 個 低 維 度 的 向 量 的 時 候 到 底 帶 來 什 麼 樣 的 幫 助 這 讓 我 想 到 神 鵰 俠 侶 的 其 中 一 段 我 不 知 道 大 家 有 沒 有 看 過 神 鵰 俠 侶 就 是 我 可 以 做 個 調 查 有 看 過 神 鵰 俠 侶 的 同 學 可 以 舉 手 一 下 嗎 哇 這 麼 多 好 手 放 下 比 我 想 像 的 多 太 多 了 我 還 以 為 現 在 大 家 已 經 沒 有 在 看 金 庸 了 這 個 神 鵰 俠 侶 裡 面 有 一 段 就 是 楊 過 進 去 那 個 絕 情 谷 遇 到 這 個 絕 情 谷 谷 主 公 孫 止 的 弟 子 就 是 樊 一 翁 樊 一 翁 就 是 這 個 人 那 樊 一 翁 的 武 器 是 什 麼 他 的 武 器 除 了 一 根 鋼 杖 以 外 還 有 他 的 鬍 子 他 可 以 去 甩 動 他 的 鬍 子 當 做 一 個 軟 鞭 來 使 用 他 的 鬍 子 甩 起 來 有 兩 丈 那 麼 長 可 以 是 一 個 很 厲 害 的 武 器 楊 過 跟 他 打 了 很 久 都 難 分 上 下 突 然 呢 楊 過 說 我 在 三 招 之 內 一 定 要 剪 掉 你 的 鬍 子 大 家 突 然 都 很 詫 異 想 說 楊 過 雖 然 武 功 可 能 比 樊 一 翁 還 高 一 點 但 是 也 沒 有 高 太 多 怎 麼 有 辦 法 三 招 就 剪 掉 他 的 鬍 子 後 來 楊 過 真 的 在 三 招 內 剪 掉 他 的 鬍 子 為 什 麼 呢 因 為 楊 過 發 現 說 這 個 鬍 子 是 由 頭 所 操 控 的 雖 然 鬍 子 甩 開 來 有 兩 丈 那 麼 長 但 是 頭 能 夠 做 的 變 化 還 是 有 限 的 所 以 雖 然 表 面 鬍 子 的 鞭 法 非 常 地 厲 害 但 是 只 要 直 接 去 打 他 的 頭 就 直 接 去 打 他 臉 就 會 逼 著 他 不 得 不 閃 避 就 會 逼 著 他 這 個 鬍 子 能 夠 動 的 路 線 變 得 有 限 然 後 就 打 敗 了 樊 一 翁 就 把 他 的 鬍 子 剪 掉 了 故 事 結 束 那 這 個 跟 auto-encoder 有 什 麼 關 係 呢 好 我 們 來 想 一 下 auto-encoder 這 件 事 情 它 要 做 的 是 把 一 張 圖 片 壓 縮 又 還 原 回 來 但 是 還 原 這 件 事 情 為 什 麼 能 成 功 呢 你 想 想 看 假 設 本 來 圖 片 是 3×3 3×3 很 小 但 我 們 就 假 設 3×3 好 了 本 來 的 圖 片 是 3×3 你 要 用 9 個 數 值 來 描 述 一 張 3×3 的 圖 片 假 設 encoder 輸 出 的 這 個 向 量 是 二 維 的 我 們 怎 麼 有 可 能 從 二 維 的 向 量 去 還 原 3×3 的 圖 片 還 原 9 個 數 值 呢 我 們 怎 麼 有 辦 法 把 9 個 數 值 變 成 2 個 數 值 又 還 原 成 3 又 還 原 回 9 個 數 值 呢 能 夠 做 到 這 件 事 情 是 因 為 對 於 影 像 來 說 並 不 是 所 有 3×3 的 矩 陣 都 是 圖 片 圖 片 的 變 化 其 實 是 有 限 的 你 隨 便 sample 一 個 random 的 noise 隨 便 sample 一 個 矩 陣 出 來 它 通 常 都 不 是 你 會 看 到 的 圖 片 或 舉 例 來 說 假 設 圖 片 是 3×3 的 那 它 的 變 化 雖 然 表 面 上 應 該 要 有 3×3 個 數 值 才 能 夠 描 述 3×3 的 圖 片 但 是 也 許 它 的 變 化 實 際 上 是 有 限 的 也 許 你 把 圖 片 蒐 集 起 來 發 現 說 它 只 有 這 樣 子 的 類 型 跟 這 樣 子 的 類 型 其 他 類 型 根 本 就 不 是 你 一 般 在 訓 練 的 時 候 會 看 到 的 狀 況 就 是 因 為 說 圖 片 的 變 化 還 是 有 限 的 所 以 你 在 做 這 個 encoder 的 時 候 encoder 可 以 說 我 就 只 用 兩 個 維 度 就 可 以 描 述 一 張 圖 片 雖 然 圖 片 是 3×3 應 該 用 9 個 數 值 才 能 夠 儲 存 但 是 實 際 上 它 的 變 化 也 許 只 有 兩 種 類 型 那 你 就 可 以 說 看 到 這 種 類 型 我 就 左 邊 這 個 維 度 是 1 右 邊 是 0 看 到 這 種 類 型 就 左 邊 這 個 維 度 是 0 右 邊 這 個 維 度 是 1 那 所 以 對 應 到 剛 才 這 個 樊 一 翁 的 例 子 就 是 這 個 鬍 子 是 圖 片 複 雜 的 狀 態 是 原 來 的 圖 片 是 原 來 圖 片 的 pixel 是 原 來 圖 片 的 像 素 而 encoder 做 的 事 情 就 是 化 繁 為 簡 本 來 比 較 複 雜 的 東 西 它 只 是 表 面 上 比 較 複 雜 事 實 上 它 的 變 化 其 實 是 有 限 的 你 只 要 找 出 它 有 限 的 變 化 你 就 可 以 把 本 來 複 雜 的 東 西 把 它 變 得 用 比 較 簡 單 的 方 法 來 表 示 它 如 果 我 們 可 以 把 複 雜 的 圖 片 用 比 較 簡 單 的 方 法 來 表 示 它 那 我 們 就 只 需 要 比 較 少 的 訓 練 資 料 在 下 游 的 任 務 裡 面 我 們 可 能 就 只 需 要 比 較 少 的 訓 練 資 料 就 可 以 讓 機 器 學 到 我 們 本 來 要 它 學 的 事 情 這 個 就 是 auto-encoder 的 概 念 那 auto-encoder 它 從 來 都 不 是 一 個 新 的 想 法 它 真 的 是 非 常 非 常 地 有 歷 史 舉 例 來 說 在 這 個 hinton 大 家 知 道 hinton 吧 hinton 就 是 deep learning 之 父 hinton 在 06 年 的 science 的 paper 裡 面 就 有 提 到 auto-encoder 這 個 概 念 只 是 那 個 時 候 用 的 network 跟 今 天 用 的 network 當 然 還 是 有 很 多 不 一 樣 的 地 方 我 們 講 2006 年 是 15 年 前 15 年 前 的 auto-encoder 長 什 麼 樣 子 那 個 時 候 人 們 不 覺 得 deep 的 network 是 train 得 起 來 的 那 時 候 覺 得 說 這 個 把 network 疊 很 多 很 多 層 然 後 每 一 層 一 起 train 不 太 可 能 成 功 所 以 那 時 候 的 信 念 是 每 一 層 應 該 分 開 訓 練 所 以 hinton 用 的 是 一 個 叫 做 restricted boltzmann machine 的 技 術 縮 寫 是 rbm 我 們 特 別 把 hinton 15 年 前 的 文 章 把 它 的 裡 面 的 這 個 paper 裡 面 的 圖 拿 出 來 給 大 家 看 一 下 過 去 15 年 前 人 們 是 怎 麼 看 待 深 度 學 習 這 個 問 題 那 個 時 候 覺 得 說 要 train 一 個 這 個 很 深 的 network 不 太 可 能 每 一 層 分 開 要 train 雖 然 這 個 說 很 深 也 沒 有 很 深 只 是 三 層 這 個 跟 你 作 業 2 做 得 還 要 更 shallow 對 不 對 但 是 在 15 年 前 這 個 已 經 是 哇 很 深 啊 它 有 三 層 太 可 怕 了 好 那 這 個 三 層 要 分 開 來 訓 練 才 可 以 那 這 邊 說 分 開 來 訓 練 這 件 事 情 叫 做 pretraining 但 它 跟 self-supervised learning 的 pre-train 又 不 一 樣 大 家 了 解 我 的 意 思 嗎 假 設 你 說 auto-encoder 這 個 東 西 是 pre-train 那 現 在 這 個 pre-train 是 pre-train 的 pre-train 它 是 要 pre-train 那 個 auto-encoder 而 且 每 一 層 用 一 個 叫 做 rbm 的 技 術 分 開 來 訓 練 先 把 每 一 層 都 訓 練 好 再 全 部 接 起 來 做 微 調 這 件 事 情 那 這 邊 的 微 調 並 不 是 bert 的 微 調 它 是 微 調 那 個 pre-train 的 model 好 那 這 個 restricted boltzmann machine 你 會 發 現 今 天 很 少 有 人 在 提 到 它 了 它 其 實 不 是 一 個 deep learning 的 技 術 它 有 點 複 雜 我 們 在 這 門 課 裡 面 也 沒 有 打 算 要 深 入 細 講 什 麼 是 restricted boltzmann machine 那 為 什 麼 現 在 都 沒 有 什 麼 人 用 它 呢 就 是 因 為 它 沒 有 什 麼 用 這 樣 子 在 過 去 呢 在 10 年 前 呢 都 相 信 這 個 deep 的 network 一 定 要 用 restricted boltzmann machine 然 後 其 實 hinton 後 來 在 2012 年 的 時 候 有 一 篇 paper 偷 偷 在 結 尾 下 一 個 結 論 說 其 實 restricted boltzmann machine 也 沒 有 什 麼 必 要 哈 哈 哈 這 樣 子 所 以 後 來 就 沒 有 什 麼 人 再 用 restricted boltzmann machine 而 且 那 時 候 還 有 一 個 神 奇 的 信 念 是 覺 得 說 那 個 encoder decoder 它 必 須 是 對 稱 所 以 encoder 的 第 一 層 跟 encoder 的 最 後 跟 decoder 的 最 後 一 層 他 們 必 須 互 為 transpose 不 過 現 在 已 經 沒 有 比 較 少 有 人 在 使 用 這 樣 子 的 限 制 好 這 張 投 影 片 只 想 告 訴 你 說 auto-encoder 不 是 新 的 概 念 它 是 一 個 非 常 有 歷 史 的 概 念 那 auto-encoder 還 有 一 個 常 見 的 變 形 叫 做 de-noising 的 auto-encoder de-noising 的 auto-encoder 是 說 我 們 把 原 來 要 輸 進 去 給 encoder 的 圖 片 加 上 一 些 雜 訊 就 自 己 隨 便 找 一 個 雜 訊 把 它 加 進 去 然 後 一 樣 通 過 encoder 一 樣 再 通 過 decoder 試 圖 還 原 原 來 的 圖 片 那 我 們 現 在 還 原 的 不 是 encoder 的 輸 入 encoder 的 輸 入 的 圖 片 是 有 加 雜 訊 的 我 們 要 還 原 的 不 是 encoder 的 輸 入 我 們 要 還 原 的 是 加 入 雜 訊 以 後 的 結 果 加 入 雜 訊 說 錯 加 入 雜 訊 之 前 的 結 果 所 以 你 會 發 現 說 現 在 encoder 跟 decoder 除 了 還 原 原 來 的 圖 片 這 個 任 務 以 外 它 還 多 了 一 個 任 務 這 個 任 務 是 什 麼 這 個 任 務 就 是 它 必 須 要 自 己 學 會 把 雜 訊 去 掉 encoder 看 到 的 是 沒 有 雜 訊 的 圖 片 但 decoder 要 還 原 的 目 標 是 encoder 看 到 的 是 有 加 雜 訊 的 圖 片 但 decoder 要 還 原 的 目 標 是 沒 有 加 雜 訊 的 圖 片 所 以 encoder 加 decoder 他 們 合 起 來 必 須 要 聯 手 能 夠 把 雜 訊 去 掉 這 樣 你 才 能 夠 把 de-noising 的 auto-encoder 訓 練 起 來 那 說 到 de-noising 的 auto-encoder 有 沒 有 發 現 這 個 概 念 其 實 也 一 點 都 不 陌 生 呢 de-noising 的 auto-encoder 也 不 算 是 太 新 的 技 術 至 少 在 2008 年 的 時 候 就 已 經 有 相 關 的 論 文 了 但 是 如 果 你 看 今 天 的 bert 的 話 其 實 你 也 可 以 把 它 看 作 就 是 一 個 de-noising 的 auto-encoder 輸 入 我 們 會 加 masking 那 些 masking 其 實 就 是 noise bert 的 模 型 就 是 encoder 它 的 輸 出 就 是 embedding 在 講 bert 的 技 術 的 時 候 我 們 就 告 訴 你 說 這 個 輸 出 就 叫 做 embedding 接 下 來 有 一 個 linear 的 模 型 就 是 decoder decoder 要 做 的 事 情 就 是 還 原 原 來 的 句 子 也 就 是 把 填 空 題 被 蓋 住 的 地 方 把 它 還 原 回 來 所 以 我 們 可 以 說 bert 其 實 就 是 一 個 de-noising 的 auto-encoder 有 同 學 可 能 會 問 說 為 什 麼 這 個 decoder 一 定 要 linear 的 呢 它 不 一 定 要 是 linear 它 可 以 不 是 linear 或 者 是 我 們 換 一 個 說 法 這 個 bert 它 有 12 層 最 小 的 那 個 bert 有 12 層 比 較 大 的 有 24 層 或 者 是 48 層 好 那 最 小 的 bert 是 12 層 如 果 我 們 說 這 個 12 層 中 間 第 6 層 的 輸 出 是 embedding 那 你 其 實 也 可 以 說 剩 下 的 6 層 就 是 decoder 你 可 以 說 bert 就 假 設 你 在 用 bert 的 時 候 你 用 的 不 是 第 12 層 的 輸 出 而 是 第 6 層 的 輸 出 那 你 完 全 可 以 說 bert 的 前 6 層 就 是 encoder 後 面 6 層 就 是 decoder 總 之 這 個 decoder 沒 有 一 定 要 是 linear
Alright, next we're going to discuss Auto-Encoder That Auto-Encoder We will probably discuss a short part first, and then We'll take a break And then I will complete the part about the Auto-Encoder And then later, the teaching assistant will discuss The assignment related to Auto-Encoder Alright, let's discuss the Auto-Encoder Before we discuss Auto-Encoder, Auto-Encoder can actually be considered as a part of Self-Supervised Learning. So, let's take a very short time to look at the framework of Self-Supervised Learning. How does Self-Supervised Learning work? First, you have a large amount of unlabeled data, using these unlabeled data You can go to train a model You have to invent some tasks that don't require annotated data For example, doing fill-in-the-blanks For example, predicting the next Token You have to think of some tasks that don't require annotated data To train your model This learning without annotated data is called Self-Supervised Learning Or some people call it Pre-Training That uses these tasks that don't need annotation data Once a model is learned It doesn't have much use by itself BERT can only fill in the blanks GPT can only complete a sentence But you can use it in other downstream tasks You can use the Self-Supervised Learning Model Make a little minor adjustment It can be used in downstream tasks In these Self-Supervised Learning tasks In tasks where learning can occur without labeled data Before there was BERT and GPT There was actually an older task An even older task that doesn't require labeled data It is called Auto-Encoder So you can also think of Auto-Encoder Consider it as self-supervised learning A kind of Pre-Train method Of course, not everyone might agree with this viewpoint while some may refer to this as an Auto-Encoder, It's not really Self-Supervised Learning This Auto-Encoder has been around for a while It already existed 15 years ago, in 2006 And then, Self-Supervised Learning is The term only exists since 19 years So the Auto-Encoder It's not part of Self-Supervised Learning Well, this is a matter of perspective The issue of defining these terms Really, we don't need to get too hung up on this point From Self-Supervised Learning It doesn't need Label Data for training From this perspective I believe Auto-Encoder can be considered as One of the methods of Self-Supervised Learning, It's like filling in the gaps, predicting The upcoming Token is a very similar concept It's just that we use a different idea Okay, let's take a look next How does the Auto-Encoder work Okay, so how does Auto-Encoder work? Now we Because we were just discussing Self-Supervised Learning. We always use text as examples Now, we're using an image as an example Assume you have a massive amount of pictures In the Auto-Encoder, you have two networks One is called the Encoder One called Decoder They are two Networks What are these two networks doing This is what the two Networks do The Encoder reads an image It turns this picture into a vector The Encoder could be many layers of CNN Load a picture Its output is a vector Following this, the vector will become the input for the Decoder Decoder will generate an image So, the architecture of the Decoder’s Network It might be like the Generator in GAN It outputs an image from 11 vectors Whether it's the Encoder or the Decoder After all, it's a multi-layered Network So what is our training objective now? The goal of training is to hope that The input of the Encoder and the output of the Decoder The closer, the better If you consider a picture as a long vector we hope that this vector is aligned with the output of the Decoder. This vector The closer the distance between these two vectors, the better Some people also call this Reconstruction It's called reconstruction Because we just take a picture Compressed into a vector Next, the Decoder needs to rely on this vector To reconstruct the original image We hope for the result of the original input The closer to the rebuilt result, the better At this point, you might realize This thing, this concept seems familiar Yes, when we're talking about Cycle GAN I've explained this concept, haven't I We said when doing Cycle GAN We will need two Generators The first Generator Transferring images from X Domain to Y Domain Another one is Generator Convert the images from the Y Domain back. Hoping for the original picture The closer the picture is to the twice-transformed image, the better Here, the Encoder and the Decoder This is the concept of Auto-Encoder It's actually the same as Cycle GAN All pictures are expected to go through two transformations The closer it is to the original output, the better And the process of this training Completely unnecessary for any annotation data All you need is to collect a large number of pictures You can do this training So, it uses unsupervised learning And the series of Self-Supervised The method is the same as Pre-Training You don't need any marked data at all The output of an Encoder like this, Sometimes we call it Embedding When we talk about BERT We have also brought up the term Embedding Some people call it Representation Some people call it Code Because an Encoder is a code, right? So, some people call this Vector as 'Code' Which actually refers to the same thing Alright, so how do we use this Auto-Encoder technology How to train the Auto-Encoder How can it be used in downstream tasks? A common usage is The original image You can also think of it as a very long vector But this vector is too long, it's not easy to handle What should we do then After you throw this picture into the Encoder, Output another vector You would want to make this vector shorter For instance, only in 10 dimensions or only in 100 dimensions Then you use this new vector for your next task That is, the image is no longer a high-dimensional vector After being compressed by the Encoder Turned it into a low-dimensional vector Then take this low-dimensional vector, To do what you want to do next This is quite common Auto-Encoder is used in downstream tasks Methods used in downstream tasks Because usually the input of the Encoder It is a vector with very high dimensions And the output of the Encoder Which is our Embedding Representation or Code It is a very low-dimensional vector For instance, if the input is a 100×100 image Then 100×100 is a 10,000-dimensional vector If it is RGB, it is a vector of 30,000 dimensions But typically the Output of the Encoder is set very small For example, levels like 10 100 So, there is a particularly narrow part here So, this section The output of this Encoder Sometimes also referred to as Bottleneck Called bottleneck The original input was very broad. The output is also very wide, especially narrow in the middle That's why this part is called a Bottleneck. And what the Encoder does Transforming something that was initially high-dimensional. Turn into low-dimensional things Turning high-dimensional stuff into low-dimensional stuff Also called Dimension Reduction Dimension Reduction, this technique I believe you have experience in Machine Learning applications You should hear this term often The technology related to Dimension Reduction It actually involves a very wide range So we will no longer elaborate on this here Because of this course We are solely focusing on techniques related to deep learning You can use the Encoder of the Auto-Encoder is used for Dimension Reduction, There are still many other methods that aren't based on Deep Learning Not based on deep learning Dimension Reduction technique I'll leave the link to the video recording here. For example, PCA or T-SNE I'll leave the video link here for everyone's reference Well, what make Auto-Encoder so good When we look at a high-dimensional image When it becomes a low-dimensional vector After all, what kind of help does it provide? This reminds me of a part in The Condor Heroes I don't know if you guys have seen The Return of Condor Heroes I can conduct an investigation Can students who have watched 'The Condor Heroes' raise their hands? Wow, so many, alright, hands down That's way more than I imagined I thought everyone had stopped reading Jin Yong by now There's a section within this Swordsman couple, It's when Yang Guo entered the Loveless Valley. Encountering a disciple of the unfeeling valley master Gongsun Zhi It is Fan Yi Weng Fan Yi Weng is this person What is Fan Yi Wen's weapon His weapon, besides a steel staff, And his beard he can use his beard as a sort of soft whip, His beard is flung about two Zhangs long, It can be a powerful weapon Yang Guo and him had a very long fight with no clear winner Suddenly, Yang Guo said I must trim your beard within three moves Everyone is suddenly very surprised We could say Yang Guo's martial arts could be slightly superior to Fan YiWen's But it's not much higher How could one possibly cut off his beard in three moves Later on, Yang Guo really did cut off his beard within three moves Why is that? Because Yang Guo realized that This mustache is controlled by the head. Even though the beard swings two meters long But the changes that can be made to the head are still limited So although the surface mustache's whipping method is very good But just aim directly at his head Just go straight for his face This forces it to dodge It will force the range of his beard movement to become limited And then defeated Fan Yi-Weng Just cut off its mustache. The story ends So, what does this have to do with Auto-Encoder? Okay, let's think about it What the Auto-Encoder has to do It's about compressing an image and restoring it But why is this reconstruction successful? Think about it, suppose the original picture is 3×3 3×3 is very small But let's just assume 3x3 The original picture was 3x3. You're using 9 values to describe a 3x3 image Assume that the vector output by the Encoder is two-dimensional How could we possibly from a two-dimensional vector... To reconstruct a 3x3 image How to restore the nine values? How can we transform nine numerical values into just two? Also restored to 3 And it's been restored to 9 values The reason it can do this is because Regarding the image, Not all 3x3 matrices are images The changes in the images are actually limited You can sample any random noise Randomly sample a matrix The output is not usually the picture you would see Or for instance Assume the picture is 3x3 Then its changes Although on the surface there should be 3×3 values This allows it to describe a 3x3 picture But perhaps its changes are actually limited Maybe you collected the images and found out It only has this type of category With this type of thing Other types are not at all The situation you would typically see when training This is because the variation in images is still limited So when you're working on this Encoder We could say Encoder I can describe an image with just two dimensions Although the image is 3×3 Nine numbers should be used for storage But in fact, its changes may only be of two types Then, you could say when you see this kind of type On the left corner, the dimension is 1, while on the right it is 0 When you see this type, the dimension on the left is 0 The dimension on the right is 1 So, corresponding to the example of Fan Yi-Ong just now It's like this beard represents the complexity of the image It's the original picture Is the original picture's Pixel It is the original pixel of the image What the Encoder does is simplify complexity Originally, more complex things It's just more complex on the surface In fact, its changes are limited You just need to find its limited changes You could simplify complex things Try to simplify it and represent it in a more straightforward way. If we can handle complex images, Expresses it in a simpler way We only require lesser training data In the downstream tasks, We might only need less training data This allows the machine to learn What we were originally trying to teach it This is the concept of Auto-Encoder That Auto-Encoder It has never been a new concept. It really has a great history For example, in this Hinton You all know Hinton, right Hinton is considered the father of Deep Learning It's in the paper Hinton published in Science in 2006. We also mentioned the concept of Auto-Encoder It was just the network used at that time It's similar to the network we're using today. Of course, there are still many differences We said that 2006 was just 15 years ago What the Auto-Encoder looked like 15 years ago There was a time when people didn't notice Deep Network can be trained At that time, it seemed to stack many layers of Network Then training every layer together is unlikely to succeed So the belief back then was Each layer should be trained separately So what Hinton used is called The technique of the Restricted Boltzmann Machine The abbreviation is RBM We particularly took an article by Hinton from 15 years ago Within it, We'll take out the diagram from the paper for everyone to see 15 years ago How do people perceive the issue of deep learning? At that time, I thought Training such a deep network is unlikely Each layer needs to be trained separately Although this seems deep, it's not really deep It's only three layers This is even more shallow than your Homework 2 Right or not? But this was already the case 15 years ago Wow, it's pretty deep. It has three layers, which is quite scary. Well, these three layers need to be trained separately The act of training them separately is called Pretraining. But it's related to the pre-training of Self-Supervised Learning It's different Does everyone understand what I mean? Assuming you say the Auto-Encoder is Pre-Train What is this Pre-Train now? The pre-training of pre-training It's for pre-training that Auto-Encoder And each layer uses a technique called RBM Train separately Train each layer first, Combine them all for fine-tuning The fine-tuning here is not BERT's fine-tuning Is it fine-tuning the pre-trained model? Well then, this Restricted Boltzmann Machine You will find that very few people mention it today In fact, it's not a Deep Learning technique it is a bit complex, We didn't intend to go into detail in this course What is a Restricted Boltzmann Machine Then why isn't it widely used now? That's because it's not really useful In the past, ten years ago They all believe in this Deep Network You must use Restricted Boltzmann Machine Actually, Hinton later on in 2012 There's a paper that subtly draws a conclusion at the end, Actually, it is a Restricted Boltzmann Machine. No need to laugh about it like this So later not many people used it Restricted Boltzmann Machine And there was also a magical belief at that time some might think of an Encoder-Decoder, It must be symmetrical So, the first layer of Encoder With the end of the Encoder connected with the final layer of the Decoder, They must be each other's transpose However, there's nothing left now Fewer people are using such restrictions Okay, this slide just wants to tell you that Auto-Encoder is not a new concept It's a concept with a significant history That Auto-Encoder also has a common variation It's called a De-Noising Auto-Encoder The 'De-Noising' Auto-Encoder means We feed the original image to the Encoder Add some noise Just arbitrarily add some noise into it Then pass it through the Encoder as usual It then passes through the Decoder again Attempting to restore the original image What we are restoring now It's not an input to the Encoder. The input image of the encoder has noise added What we need to restore is not the Encoder's input what we aim to restore is the result after noise introduction, Added noise, I misspoke The result before adding noise So you will find that Now Encoder and Decoder Apart from the task of restoring the original image It has an additional task What is this task? This is the task It needs to learn to remove the noise by itself The encoder sees an image without noise But the target to be restored by the Decoder is What the Encoder sees is a picture with added noise But the goal of Decoder is Pictures without the addition of noise So, combine Encoder and Decoder They have to team up to eliminate the noise Only in this way can you Training a De-Noising Auto-Encoder Speaking of the De-Noising Auto-Encoder Have you noticed this concept? Actually, it's not unfamiliar at all A De-noising Auto-Encoder It's not exactly a new technology At least in 2008 There are already related papers But if you look at BERT today In fact, you can see it as one of De-noising Auto-Encoder We add masking to the input Those Maskings are actually Noise The model of BERT is the Encoder Its output is Embedding When discussing the technology of BERT Let's just say this output is called Embedding Next, there is a Linear model It's the Decoder The tasks for the decoder It's about restoring the original sentence, In other words, it's covering the gap in the fill-in-the-blank question Restoring it back So, we can say BERT is actually De-Noising Auto-Encoder Some students might ask Why does this Decoder have to be linear? It doesn't have to be Linear It doesn't have to be Linear Or, we can say it another way This BERT has 12 layers The smallest BERT has 12 layers The larger ones have 24 layers, or some even have 48 layers Alright, the smallest BERT has 12 layers If we say this is in the middle of 12 layers The output of the 6th layer is Embedding You could actually say the remaining 6 layers It is the Decoder You can refer to BERT Suppose that you are using BERT, What you're using is not the output of the 12th layer But rather, the 6th layer's output Then you can absolutely say The first 6 layers of BERT are the Encoder The last 6 layers are the Decoder Anyway, this Decoder There's no necessity for it to be Linear
week10_2.wav
好 我 們 來 講 一 下 那 個 下 一 個 主 題 我 們 來 講 那 個 adversarial 的 attack adversarial attack 要 講 這 個 主 題 要 講 的 是 什 麼 呢 我 們 這 邊 要 講 的 是 我 們 在 作 業 裡 面 我 們 已 經 訓 練 了 非 常 多 各 式 各 樣 的 類 神 經 網 路 那 我 們 當 然 期 待 說 我 們 可 以 把 這 些 技 術 用 在 真 正 的 應 用 上 但 是 光 是 把 這 些 network 用 在 真 正 的 應 用 上 要 把 這 些 network 用 在 真 正 應 用 上 光 是 它 們 正 確 率 高 是 不 夠 的 它 們 還 需 要 什 麼 能 力 呢 他 們 需 要 能 夠 應 付 來 自 人 類 的 惡 意 什 麼 叫 做 來 自 人 類 的 惡 意 呢 有 時 候 你 的 network 它 的 工 作 是 為 了 要 偵 測 一 些 有 惡 意 的 行 為 如 果 今 天 它 的 工 作 是 要 偵 測 有 惡 意 的 行 為 這 些 它 要 偵 測 的 對 象 會 去 想 辦 法 騙 過 network network 在 一 般 的 情 況 下 都 可 以 得 到 高 的 正 確 率 是 不 夠 的 它 要 在 有 人 試 圖 想 要 欺 騙 它 的 情 況 下 也 得 到 高 的 正 確 率 舉 例 來 說 我 們 今 天 都 會 用 network 來 做 e-mail 的 filtering 你 會 用 network 來 做 偵 測 一 封 郵 件 它 是 不 是 垃 圾 郵 件 那 今 天 對 於 一 個 垃 圾 郵 件 的 發 信 者 而 言 他 也 會 想 盡 辦 法 避 免 他 的 郵 件 被 分 類 為 垃 圾 郵 件 如 果 今 天 有 人 他 想 辦 法 去 更 改 郵 件 的 內 容 想 要 去 欺 騙 過 network 的 話 那 network 到 底 能 不 能 不 要 被 欺 騙 呢 所 以 今 天 我 們 希 望 我 們 的 類 神 經 網 路 它 光 是 正 確 率 高 還 不 夠 我 們 希 望 它 可 以 應 付 來 自 人 類 的 惡 意 舉 例 來 說 這 個 是 蟻 王 知 道 嗎 牠 叫 做 梅 路 艾 姆 牠 是 站 在 生 物 頂 點 牠 是 生 物 頂 點 的 一 個 存 在 牠 非 常 地 強 人 類 沒 有 辦 法 打 贏 牠 那 牠 會 消 滅 掉 所 有 的 人 類 但 是 人 類 並 沒 有 跟 牠 打 人 類 是 不 講 武 德 的 人 類 就 直 接 放 一 個 核 彈 就 把 牠 炸 死 然 後 故 事 就 結 束 了 就 這 樣 好 所 以 這 告 訴 我 們 什 麼 這 告 訴 我 們 說 network 光 是 正 確 率 高 是 不 夠 的 它 必 須 要 能 夠 應 付 來 自 人 類 的 惡 意 好 接 下 來 我 們 就 要 講 人 類 的 惡 意 可 能 是 什 麼 樣 子 我 們 先 來 看 一 個 真 正 的 例 子 我 們 今 天 在 好 多 個 作 業 裡 面 我 們 都 已 經 訓 練 了 影 像 辨 識 的 模 型 也 就 是 說 你 有 一 個 影 像 辨 識 的 系 統 給 它 一 張 照 片 它 可 以 告 訴 我 們 說 這 張 照 片 屬 於 什 麼 樣 的 類 別 那 今 天 我 們 要 做 的 事 情 是 在 這 張 照 片 上 面 加 入 一 個 非 常 小 的 雜 訊 一 張 照 片 可 以 被 看 作 是 一 個 非 常 長 的 向 量 我 們 在 這 個 非 常 長 的 向 量 上 加 入 每 一 個 維 度 都 加 入 一 個 小 小 的 雜 訊 把 這 個 有 加 入 雜 訊 以 後 的 照 片 丟 到 network 看 看 會 發 生 什 麼 樣 的 事 情 那 一 般 呢 這 個 雜 訊 都 非 常 非 常 地 小 小 到 什 麼 地 步 呢 最 好 小 到 人 肉 眼 沒 有 辦 法 看 出 來 所 以 這 個 例 子 裡 面 加 的 雜 訊 其 實 太 大 了 一 般 這 個 雜 訊 是 小 到 人 肉 眼 看 不 出 來 的 有 被 加 雜 訊 的 照 片 叫 做 attacked image 有 被 攻 擊 的 照 片 那 還 沒 有 被 加 雜 訊 的 照 片 呢 我 們 一 般 就 叫 做 benign image 它 是 好 的 image 它 是 還 沒 有 被 攻 擊 的 圖 片 benign image 丟 到 network 裡 面 它 的 輸 出 是 貓 那 我 們 期 待 說 attacked image 就 我 們 現 在 是 攻 擊 方 我 們 是 壞 人 我 們 希 望 attacked image 丟 到 network 裡 面 它 的 輸 出 不 可 以 是 貓 要 變 成 其 他 的 東 西 那 攻 擊 呢 大 致 上 可 以 分 成 兩 種 類 型 一 種 是 沒 有 目 標 的 攻 擊 沒 有 目 標 的 攻 擊 是 原 來 的 答 案 是 貓 只 要 你 能 夠 讓 network 的 輸 出 不 是 貓 你 就 算 是 成 功 了 但 是 還 有 另 外 一 種 更 困 難 的 攻 擊 是 有 目 標 的 攻 擊 也 就 是 說 我 們 希 望 network 不 止 它 輸 出 不 能 是 貓 還 要 輸 出 別 的 東 西 比 如 說 我 們 希 望 加 了 一 個 雜 訊 以 後 network 輸 出 呢 是 海 星 它 把 貓 錯 誤 判 斷 成 一 隻 海 星 才 算 是 攻 擊 成 功 好 那 這 樣 子 的 攻 擊 真 的 有 可 能 做 到 嗎 我 們 真 的 可 以 加 入 一 個 人 肉 眼 看 不 到 的 雜 訊 去 改 變 network 的 輸 出 嗎 實 際 上 是 可 以 的 這 邊 用 的 network 並 不 是 一 個 很 弱 的 network 它 是 50 層 的 resnet 當 我 們 把 一 個 benign image 沒 有 被 攻 擊 的 圖 片 丟 到 50 層 的 resnet 的 時 候 它 的 輸 出 是 tiger cat 你 知 道 今 天 這 種 影 像 辨 識 的 系 統 它 的 輸 出 都 不 只 會 告 訴 你 它 是 什 麼 動 物 還 會 告 訴 你 它 是 哪 一 個 品 種 的 動 物 所 以 它 給 它 這 隻 貓 它 不 只 說 它 是 cat 還 說 它 是 tiger cat 不 過 據 說 這 個 答 案 其 實 是 錯 的 據 說 這 個 貓 不 是 tiger cat 不 過 沒 有 關 係 反 正 它 都 認 得 出 這 個 是 一 隻 貓 就 對 了 至 少 知 道 是 一 個 貓 科 的 動 物 好 那 它 還 有 一 個 信 心 的 分 數 信 心 的 分 數 是 0.64 這 個 信 心 的 分 數 是 什 麼 呢 這 個 信 心 的 分 數 就 是 做 完 那 個 soft mask 以 後 得 到 的 那 個 分 數 就 假 設 你 的 影 像 分 類 的 類 別 有 2000 類 2000 個 類 別 都 會 有 一 個 分 數 那 這 個 分 數 呢 一 定 介 於 0 到 1 之 間 而 且 2000 個 類 別 的 分 數 合 起 來 會 剛 剛 好 是 1 那 既 然 有 2000 個 類 別 那 麼 多 tiger cat 可 以 拿 到 0.64 的 分 數 那 其 實 算 是 挺 高 的 接 下 來 呢 我 們 在 這 個 benign image 上 面 加 入 一 些 雜 訊 我 們 現 在 希 望 成 功 攻 擊 的 目 標 是 把 tiger cat 變 成 海 星 而 被 攻 擊 以 後 的 圖 片 長 的 是 這 個 樣 子 的 你 可 能 問 說 雜 訊 加 在 哪 裡 呢 雜 訊 已 經 加 進 去 了 但 它 非 常 非 常 地 小 小 到 人 的 肉 眼 根 本 沒 有 辦 法 看 出 來 把 這 張 圖 片 丟 到 resnet 以 後 會 發 生 什 麼 事 呢 resnet 的 output 變 成 star fish 而 且 它 的 信 心 分 數 是 100 % 啊 本 來 它 還 沒 有 那 麼 確 定 這 是 不 是 一 隻 貓 現 在 它 百 分 之 百 確 定 它 就 是 海 星 那 為 了 要 證 明 說 這 兩 張 照 片 還 是 有 一 些 不 一 樣 的 我 們 把 它 做 一 下 相 減 光 做 相 減 是 不 夠 的 做 完 相 減 以 後 還 要 把 它 們 的 差 距 放 大 50 倍 你 會 得 到 這 樣 子 的 結 論 所 以 這 兩 張 照 片 確 實 有 些 不 一 樣 我 並 不 是 把 同 一 張 照 片 複 製 兩 次 來 騙 你 它 們 是 有 一 點 不 一 樣 的 但 是 人 根 本 看 不 出 這 點 不 一 樣 會 造 成 什 麼 樣 的 影 響 但 是 對 resnet 而 言 它 卻 有 了 天 差 地 遠 的 輸 出 那 也 許 有 人 會 覺 得 說 啊 也 許 是 因 為 貓 跟 海 星 有 什 麼 特 別 的 關 係 我 們 可 以 把 貓 變 成 海 星 只 是 一 個 特 例 這 不 是 一 個 特 例 你 可 以 把 這 隻 貓 輕 易 地 變 成 任 何 的 東 西 我 完 全 可 以 加 上 另 外 一 個 雜 訊 就 讓 這 隻 貓 變 成 一 個 鍵 盤 它 一 樣 信 心 分 數 高 達 0.98 本 來 不 太 確 定 它 是 不 是 貓 現 在 加 入 另 外 一 個 雜 訊 以 後 network 98% 確 定 它 就 是 一 個 鍵 盤 那 有 人 可 能 會 覺 得 說 欸 怎 麼 會 發 生 這 麼 離 譜 的 行 為 會 不 會 是 這 個 network 太 爛 了 我 要 告 訴 你 它 可 是 有 50 層 的 喔 它 可 不 是 一 個 非 常 爛 的 network 如 果 你 加 入 的 只 是 一 般 的 雜 訊 它 並 不 一 定 會 犯 錯 這 個 是 原 來 的 圖 片 我 們 現 在 加 入 一 個 雜 訊 這 個 雜 訊 是 你 肉 眼 可 見 的 你 可 以 很 明 顯 地 看 到 這 張 圖 片 裡 面 被 加 入 了 雜 訊 這 個 時 候 resnet 覺 得 它 看 到 的 是 tabby cat 這 可 能 才 是 正 確 答 案 但 無 論 如 何 它 都 知 道 是 貓 科 動 物 把 雜 訊 加 得 更 大 一 點 它 說 這 是 persian cat 這 是 波 斯 貓 可 能 雜 訊 加 得 大 一 點 這 個 貓 看 起 來 毛 茸 茸 的 所 以 resnet 覺 得 它 看 到 了 波 斯 貓 把 雜 訊 再 加 更 大 一 點 你 可 能 已 經 不 知 道 這 是 什 麼 東 西 了 這 個 時 候 resnet 說 它 看 到 了 fire screen fire screen 是 什 麼 呢 我 google 了 一 下 發 現 fire screen 長 這 個 樣 子 這 裡 完 全 可 以 理 解 機 器 為 什 麼 會 犯 錯 它 覺 得 前 面 的 雜 訊 是 這 個 屏 風 而 後 面 這 個 橙 色 的 貓 就 是 火 焰 它 雖 然 犯 錯 它 錯 的 是 有 尊 嚴 的 它 錯 的 是 有 道 理 的 但 不 知 道 為 什 麼 加 入 一 個 人 肉 眼 看 不 到 的 雜 訊 的 時 候 它 卻 產 生 了 天 差 地 遠 的 結 果 那 接 下 來 我 們 在 講 為 什 麼 這 件 事 會 發 生 之 前 我 們 來 看 看 剛 才 所 說 的 攻 擊 究 竟 是 如 何 做 到 的 我 們 到 底 是 怎 麼 加 入 了 一 個 非 常 微 小 的 雜 訊 而 這 個 非 常 微 小 的 雜 訊 可 以 讓 network 產 生 非 常 錯 誤 的 結 果 呢 而 這 個 是 我 們 的 network 它 是 一 個 function 我 們 叫 它 f 這 個 function 輸 入 是 一 張 圖 片 我 們 叫 它 x0 它 的 輸 出 是 一 個 distribution 這 個 是 這 個 分 類 的 結 果 那 我 們 叫 它 y0 那 我 們 這 邊 假 設 network 的 參 數 就 是 固 定 的 我 們 不 討 論 network 的 參 數 的 部 分 network 的 參 數 不 是 我 們 今 天 的 重 點 所 以 它 是 固 定 的 如 果 是 non-targeted attack 的 話 我 們 要 怎 麼 找 出 non-targeted attack 的 雜 訊 呢 我 們 現 在 要 做 的 目 標 就 是 我 們 要 找 到 一 張 新 的 圖 片 這 張 新 的 圖 片 呢 我 們 用 x 來 表 示 當 我 們 把 x 丟 到 這 個 network f 的 時 候 它 的 輸 出 是 y 而 我 們 希 望 y 呢 跟 正 確 答 案 我 們 正 確 的 答 案 叫 做 ŷ 我 們 希 望 y 跟 ŷ 它 的 差 距 越 大 越 好 我 們 現 在 是 non-targeted attack 沒 有 目 標 的 攻 擊 我 們 只 要 知 道 說 正 確 答 案 是 ŷ 今 天 network 的 輸 出 跟 正 確 答 案 的 差 距 越 大 我 們 就 算 是 攻 擊 成 功 了 那 怎 麼 做 到 這 件 事 呢 怎 麼 找 到 這 個 x 丟 到 一 個 network 裡 以 後 它 產 生 的 y 跟 ŷ 差 距 越 大 越 好 呢 我 們 一 樣 要 解 一 個 optimization 的 問 題 這 個 跟 我 們 訓 練 的 network 其 實 是 非 常 類 似 的 我 們 先 定 一 個 loss function 這 個 loss function 呢 叫 做 l 叫 做 l 這 個 l 是 什 麼 呢 這 個 l 呢 是 y 跟 ŷ 之 間 的 差 距 取 一 個 負 號 舉 例 來 說 我 們 一 般 在 做 這 個 classification 的 時 候 我 們 訓 練 的 目 標 y 跟 ŷ 都 是 看 它 的 cross entropy 那 我 們 這 個 -e(y, ŷ) 這 一 項 代 表 的 就 是 y 跟 ŷ 之 間 的 cross entropy 但 是 我 們 希 望 這 個 cross entropy 越 大 越 好 所 以 我 們 今 天 在 cross entropy 前 面 加 一 個 負 號 那 這 個 負 的 cross entropy 就 是 我 們 的 loss 而 我 們 期 望 這 個 loss 越 小 越 好 我 們 希 望 找 到 一 個 x x 可 以 讓 l(x) 越 小 越 好 l(x) 越 小 就 代 表 說 y 跟 ŷ 它 們 的 cross entropy 越 大 也 就 是 y 跟 ŷ 它 們 的 距 離 越 大 這 個 是 沒 有 目 標 的 攻 擊 如 果 是 有 目 標 的 攻 擊 的 話 那 我 們 會 先 設 定 好 我 們 的 目 標 我 們 用 y target 來 代 表 我 們 的 目 標 那 ŷ 其 實 是 一 個 one-hot vector y target 也 是 一 個 one-hot vector 那 我 們 現 在 希 望 這 個 y 不 止 跟 ŷ 越 遠 越 好 我 們 還 要 跟 y target 越 近 越 好 所 以 假 設 你 的 y target 是 一 個 fish 那 你 希 望 你 輸 出 的 這 個 y 啊 它 不 止 cat 的 機 率 越 低 越 好 fish 的 機 率 還 要 越 高 越 好 那 你 的 loss function 就 寫 成 這 樣 我 們 的 loss function 是 負 的 y 跟 ŷ 之 間 的 cross entropy 希 望 這 一 項 越 大 越 好 同 時 你 又 希 望 y 跟 y target 它 們 越 小 越 好 你 把 這 兩 項 加 起 來 就 是 你 的 loss 你 希 望 找 一 個 x 去 minimize 這 個 loss 但 光 是 找 一 個 x 去 minimize loss 是 不 夠 的 因 為 我 們 其 實 還 期 待 說 我 們 加 入 的 雜 訊 越 小 越 好 也 就 是 我 們 新 找 到 的 圖 片 可 以 欺 騙 過 network 的 圖 片 跟 原 來 的 圖 片 要 越 相 近 越 好 x 跟 x0 要 越 近 越 好 所 以 我 們 在 解 這 個 optimization 的 problem 的 時 候 我 們 還 會 多 加 入 一 個 限 制 這 個 限 制 是 d(x0,x) 它 小 於 等 於 σ 那 這 個 d(x0,x) 小 於 等 於 σ 是 什 麼 意 思 呢 它 的 意 思 就 是 我 們 希 望 x 跟 x0 之 間 的 差 距 小 於 某 一 個 threshold 小 於 某 一 個 閾 值 那 這 個 閾 值 是 根 據 什 麼 東 西 來 決 定 的 呢 通 常 就 是 根 據 人 類 的 感 知 能 力 來 決 定 我 們 就 假 設 說 如 果 x 跟 x0 它 們 的 差 距 大 於 這 個 d(x0,x) 就 代 表 它 們 兩 個 之 間 的 差 距 那 等 一 下 下 一 頁 投 影 片 我 會 講 說 怎 麼 計 算 兩 張 圖 片 之 間 的 差 距 如 果 x0 跟 x 之 間 的 差 距 大 於 σ 我 們 假 設 人 就 會 看 到 這 個 雜 訊 人 就 會 發 現 有 一 個 雜 訊 存 在 所 以 我 們 要 讓 x0 跟 x 它 的 差 距 小 於 等 於 σ 小 於 等 於 人 類 可 以 感 知 的 極 限 那 我 們 就 可 以 產 生 一 張 圖 片 人 類 看 起 來 x 跟 x0 是 一 模 一 樣 的 但 產 生 的 結 果 對 network 來 說 是 非 常 不 一 樣 的 好 那 怎 麼 計 算 x 跟 x0 之 間 的 差 距 它 們 之 間 的 距 離 呢 d(x0,x) 就 代 表 它 們 之 間 的 距 離 有 各 式 各 樣 不 同 的 算 法 那 為 了 等 一 下 符 號 的 方 便 起 見 呢 我 們 假 設 x 是 一 個 向 量 因 為 它 是 個 圖 片 所 以 它 是 個 向 量 嘛 x0 是 另 外 一 張 圖 片 它 也 是 一 個 向 量 這 兩 個 向 量 相 減 我 們 叫 它 δx 那 這 個 距 離 啊 你 可 以 定 l2-norm 當 做 它 們 的 距 離 也 就 是 說 你 可 以 計 算 δx 的 l2-norm δx 的 l2-norm 就 是 把 這 個 δx 的 第 一 位 拿 出 來 取 平 方 第 二 位 拿 出 來 取 平 方 第 三 位 拿 出 來 取 平 方 在 這 邊 你 其 實 要 開 根 號 也 可 以 啦 就 看 你 的 l2-norm 的 定 義 是 怎 樣 你 要 開 根 號 也 是 可 以 的 好 那 另 外 還 有 一 個 定 義 呢 是 l-infinity l-infinity 是 怎 麼 看 的 呢 它 就 是 把 這 個 δx 拿 來 然 後 看 裡 面 哪 一 個 維 度 它 的 絕 對 值 最 大 那 這 一 個 就 是 l-infinity 就 把 δx1 δx2 δx3 也 就 是 δx 的 每 一 維 都 拿 出 來 取 絕 對 值 看 誰 最 大 最 大 的 那 一 個 就 代 表 x 跟 x0 之 間 的 距 離 好 那 有 各 種 不 同 的 方 法 可 以 計 算 兩 張 圖 片 之 間 的 距 離 但 是 我 們 在 決 定 要 使 用 哪 一 種 方 法 來 計 算 圖 片 的 距 離 的 時 候 其 實 我 們 應 該 把 人 類 的 感 知 把 它 考 慮 進 來 那 l2 跟 l-infinity 到 底 哪 一 個 在 attack 的 時 候 是 比 較 好 的 距 離 呢 以 下 我 舉 一 個 例 子 來 跟 大 家 說 明 好 這 是 一 張 圖 片 假 設 這 個 圖 片 只 有 四 個 pixel 而 已 現 在 啊 我 們 把 這 張 圖 片 做 兩 種 不 同 的 變 化 第 一 個 變 化 是 這 四 個 pixel 的 顏 色 都 做 了 非 常 小 的 改 變 第 二 種 變 化 是 只 有 右 下 角 這 個 pixel 它 的 顏 色 被 改 了 而 且 改 的 是 比 較 大 的 如 果 我 們 今 天 在 計 算 l2 的 norm 的 時 候 這 兩 張 圖 片 的 l2-norm 和 這 兩 張 圖 片 的 l2-norm 是 一 樣 的 上 面 這 張 圖 片 是 下 面 這 張 圖 片 四 個 pixel 都 改 過 以 後 的 結 果 上 面 這 個 中 間 這 個 圖 片 是 下 面 這 個 圖 片 就 下 面 這 個 圖 片 是 中 間 這 個 圖 片 只 有 右 下 角 的 pixel 改 動 以 後 的 結 果 那 這 個 改 動 是 比 較 大 的 這 兩 個 變 化 他 們 的 l2 的 norm 是 一 樣 的 而 但 是 如 果 你 看 l-infinity 的 話 它 們 是 不 一 樣 的 因 為 l-infinity 只 在 意 最 大 的 變 化 量 那 對 於 l-infinity 而 言 這 個 改 變 它 的 最 大 的 變 化 量 跟 這 個 改 變 它 最 大 的 變 化 量 下 面 這 個 改 變 它 最 大 的 變 化 量 是 比 較 大 的 上 面 這 個 改 變 最 大 的 變 化 量 是 比 較 小 那 如 果 從 這 個 例 子 來 看 l-infinity 跟 l2 哪 一 個 比 較 接 近 人 類 的 感 知 能 力 呢 也 許 應 該 是 l-infinity 吧 因 為 對 你 來 說 其 實 這 兩 張 圖 片 我 相 信 多 數 人 你 可 能 都 看 不 出 它 們 之 間 有 什 麼 差 別 那 我 跟 你 保 證 它 們 兩 個 之 間 是 有 差 別 的 就 它 們 是 有 非 常 非 常 微 小 的 差 別 只 是 它 的 差 別 是 分 布 在 每 一 個 pixel 上 面 而 這 下 面 這 兩 個 改 變 呢 你 會 很 明 顯 的 看 到 右 下 角 這 個 綠 色 它 的 顏 色 變 深 了 雖 然 這 另 外 這 三 個 pixel 的 顏 色 是 固 定 的 右 下 角 的 顏 色 一 變 深 你 就 發 現 有 圖 片 有 變 化 就 發 現 這 個 圖 片 有 做 到 有 做 了 某 種 修 改 所 以 看 起 來 l-infinity 也 許 更 符 合 實 際 的 需 求 我 們 要 避 免 被 人 類 我 們 要 避 免 被 人 類 發 現 光 是 l2 小 是 不 夠 的 我 們 要 讓 l-infinity 小 才 是 最 好 的 才 是 比 較 不 會 被 發 現 所 以 在 作 業 裡 面 我 們 是 用 l-infinity 來 當 做 我 們 的 限 制 來 當 做 攻 擊 那 我 們 作 業 就 是 要 去 攻 擊 一 個 judgeboi 上 面 的 那 個 像 辨 識 系 統 產 生 出 來 的 圖 片 我 們 會 有 所 限 制 說 新 的 圖 片 跟 舊 的 圖 片 跟 原 來 benign 圖 片 的 差 距 要 小 於 某 一 個 threshold 那 我 們 在 定 這 個 差 距 的 時 候 我 們 就 是 選 擇 l-infinity 那 實 際 上 這 個 差 距 要 怎 麼 定 才 是 比 較 好 這 個 也 要 憑 domain knowledge 我 們 剛 才 舉 的 例 子 是 影 像 上 的 例 子 如 果 我 們 今 天 要 攻 擊 的 對 象 其 實 是 一 個 跟 語 音 相 關 的 系 統 我 們 的 x 跟 x0 其 實 都 是 聲 音 訊 號 那 什 麼 樣 的 聲 音 訊 號 對 人 類 來 說 聽 起 來 有 差 距 那 就 不 見 得 是 l2 跟 l-infinity 了 你 就 要 去 研 究 人 類 的 聽 覺 系 統 看 看 人 類 對 什 麼 頻 態 的 變 化 特 別 敏 感 那 根 據 人 類 的 聽 覺 系 統 來 制 定 比 較 適 合 的 x 跟 x0 之 間 距 離 的 衡 量 方 式 那 這 個 部 分 就 是 需 要 用 到 domain knowledge 好 那 我 們 現 在 已 經 有 了 我 們 的 optimization 的 問 題 我 們 要 做 的 事 情 就 是 我 們 要 去 minimize 是 一 個 loss 那 現 在 我 們 要 找 一 個 x 去 minimize 這 個 loss 但 是 這 個 x 我 們 是 有 限 制 的 x 跟 x0 它 們 的 distance 要 小 於 等 於 x 那 這 個 問 題 到 底 要 怎 麼 解 呢 我 們 先 把 這 個 限 制 拿 掉 如 果 把 這 個 限 制 拿 掉 你 會 不 會 解 這 個 問 題 呢 你 其 實 會 解 這 個 問 題 因 為 這 跟 我 們 train 一 個 模 型 其 實 沒 有 什 麼 差 別 啊 我 們 在 第 一 堂 課 的 時 候 就 列 過 這 個 optimization 的 問 題 給 你 看 告 訴 你 說 你 可 以 調 你 的 network 的 參 數 去 讓 一 個 loss 最 小 我 們 今 天 只 是 把 參 數 改 成 network 的 input 而 已 就 這 樣 你 就 把 input 那 一 張 image 看 作 是 network 參 數 的 一 部 分 然 後 minimize 你 的 loss function 就 結 束 了 現 在 network 的 參 數 是 固 定 的 我 們 只 去 調 input 部 分 讓 input 的 部 分 去 改 變 去 minimum 一 個 loss 就 結 束 了 用 的 一 樣 是 gradient descent 怎 麼 做 呢 你 就 這 樣 做 啦 就 是 你 要 先 有 個 initialization 嘛 我 們 現 在 找 的 對 象 不 是 network 參 數 是 x 是 你 input 的 image 但 是 它 還 是 需 要 一 個 初 始 化 的 值 對 不 對 你 還 是 需 要 一 個 做 gradient descent 的 時 候 初 始 化 的 值 那 初 始 化 的 值 設 什 麼 樣 的 數 值 比 較 好 呢 你 可 能 不 會 從 隨 機 的 image 開 始 你 可 能 會 從 x0 開 始 因 為 我 們 本 來 就 希 望 說 我 們 新 找 到 的 x 應 該 跟 x0 越 接 近 越 好 嘛 那 你 何 不 就 從 x0 開 始 找 呢 你 從 x0 開 始 找 你 接 下 來 找 出 來 的 x 可 能 就 會 跟 x0 比 較 接 近 所 以 你 初 始 化 的 x 你 會 初 始 化 的 這 個 x0 就 直 接 設 x0 然 後 接 下 來 就 跟 一 般 的 gradient descent 是 一 模 一 樣 的 我 們 就 是 iterative 去 update 你 的 參 數 你 就 設 一 個 iteration t 等 於 1 到 t 然 後 在 每 一 個 iteration 裡 面 你 都 會 計 算 gradient 只 是 這 個 gradient 不 是 network 參 數 對 loss 的 gradient 我 們 現 在 已 經 不 管 network 參 數 了 而 是 input 那 一 張 image x 對 於 loss 的 gradient 那 input 這 個 x 它 也 是 一 個 很 長 的 向 量 嘛 它 裡 面 就 是 有 x1 x2 x3 嘛 你 就 去 計 算 這 個 input image 裡 面 每 一 個 數 值 對 l 的 偏 微 分 就 x1 對 l 的 偏 微 分 x2 對 l 的 偏 微 分 算 出 來 算 出 一 個 gradient 用 這 個 gradient 去 update 你 的 image 就 結 束 了 所 以 你 本 來 的 image x0 它 就 減 掉 這 個 gradient 那 前 面 你 也 會 乘 上 一 個 learning rate 就 跟 一 般 gradient descent 是 一 模 一 樣 的 只 是 要 做 gradient descent 的 對 象 從 參 數 換 成 input 而 已 其 他 都 是 一 樣 的 也 有 learning rate 那 些 什 麼 東 西 統 統 都 有 乘 上 一 個 gradient 乘 上 learning rate 減 掉 原 來 的 image 然 後 就 得 到 新 的 image 你 可 以 iteration 地 跑 就 跟 一 般 的 gradient descent 是 一 模 一 樣 的 但 是 這 個 是 在 沒 有 constraint 的 前 提 接 下 來 我 們 得 把 constraint 加 進 去 因 為 一 般 我 們 在 做 gradient descent 的 時 候 我 們 並 沒 有 把 那 個 gradient descent 的 對 象 做 什 麼 限 制 我 們 並 沒 有 設 限 說 我 們 的 參 數 一 定 要 長 什 麼 樣 子 那 現 在 我 們 是 有 限 制 的 我 們 限 制 說 x 跟 x0 他 們 的 差 距 一 定 要 小 於 等 於 ε 那 要 怎 麼 處 理 這 個 問 題 呢 你 就 在 你 的 gradient descent 裡 面 再 加 一 個 module 欸 我 發 現 說 快 那 個 5 點 20 了 今 天 我 們 需 要 在 5 點 20 左 右 就 結 束 了 所 以 我 們 等 一 下 可 能 會 需 要 講 到 一 個 段 落 就 結 束 它 這 樣 子 好 這 個 我 們 要 跑 gradient descent 這 個 演 算 法 但 是 我 們 要 同 時 考 慮 x0 跟 x 之 間 的 差 距 怎 麼 考 慮 這 件 事 情 呢 這 邊 呢 這 個 方 法 說 穿 了 不 值 錢 非 常 地 簡 單 如 果 你 update 完 你 的 參 數 以 後 發 現 x0 跟 x 我 這 邊 應 該 要 用 xt 比 較 正 確 啦 我 這 邊 應 該 要 用 xt 比 較 正 確 你 update 完 你 的 參 數 以 後 發 現 你 的 xt 跟 x0 的 差 距 大 於 ε 以 後 你 就 做 一 個 修 改 把 xt 做 個 修 改 把 它 改 回 符 合 限 制 就 結 束 了 舉 例 來 說 假 設 我 們 現 在 用 的 是 l-infinity 我 們 的 這 個 x0 在 這 個 地 方 那 我 們 的 x 它 可 以 存 在 的 範 圍 就 只 有 這 個 方 形 框 框 的 範 圍 對 不 對 因 為 l-infinity 是 考 慮 x0 跟 x 之 間 最 大 的 差 距 所 以 出 了 這 個 框 架 的 差 距 就 會 超 過 ε 所 以 今 天 呢 你 在 做 完 這 個 gradient descent 用 gradient 去 update 你 的 x 以 後 它 一 定 還 是 得 要 落 在 這 個 框 框 裡 面 才 行 那 怎 麼 保 證 update 以 後 一 定 落 在 這 個 框 框 裡 面 呢 你 就 只 要 update 超 出 了 框 框 就 把 它 拉 回 來 就 結 束 了 所 以 今 天 這 個 步 驟 如 果 做 完 你 發 現 你 得 到 藍 色 這 個 點 跑 出 框 框 了 怎 麼 辦 在 框 框 裡 面 找 一 個 跟 藍 色 的 點 最 近 的 位 置 把 藍 色 的 點 拉 進 來 就 結 束 了 就 結 束 了 好 那 其 實 這 種 attack 有 非 常 多 不 同 的 變 形 我 想 你 在 文 獻 上 可 以 找 到 各 式 各 樣 的 attack 方 法 但 其 實 它 們 的 精 神 都 不 脫 我 們 今 天 講 的 這 個 事 情 那 它 們 通 常 不 一 樣 的 地 方 都 是 要 嘛 是 constraint 不 一 樣 要 嘛 是 optimization 的 方 法 不 一 樣 但 是 通 常 都 還 是 用 gradient descent 它 們 的 精 神 還 是 一 樣 的 只 是 這 邊 你 可 能 會 有 不 同 的 optimizer 這 邊 你 可 能 會 有 不 同 的 限 制 它 就 變 成 不 同 的 attack 方 法 但 它 們 精 神 都 不 脫 我 們 今 天 跟 大 家 舉 的 這 個 例 子 好 那 接 下 來 呢 我 們 跟 大 家 介 紹 一 個 最 簡 單 的 attack 的 方 法 也 是 作 業 裡 面 你 要 過 這 個 應 該 是 過 medium baseline 所 用 的 方 法 然 後 這 個 方 法 是 什 麼 呢 這 個 方 法 它 叫 做 fgsm 它 可 以 過 medium baseline 嗎 喔 它 不 能 過 medium baseline 它 只 能 過 simple baseline 好 這 個 fgsm 它 是 怎 麼 做 的 呢 非 常 地 簡 單 它 叫 做 fast gradient sign method 縮 寫 它 怎 麼 做 呢 它 就 像 是 一 個 一 拳 超 人 一 樣 它 只 用 一 擊 本 來 一 般 你 在 做 gradient descent 的 時 候 你 要 update 參 數 很 多 次 但 是 fgsm 它 厲 害 的 地 方 就 是 它 決 定 只 update 一 次 參 數 看 看 能 不 能 夠 一 擊 必 殺 一 擊 就 找 出 一 個 可 以 attack 成 功 的 image 所 以 首 先 呢 本 來 要 iterative 的 去 update 參 數 但 是 現 在 不 用 我 們 只 做 一 次 的 攻 擊 我 們 只 做 一 次 的 attack 然 後 g 這 邊 呢 它 做 了 一 個 特 別 的 設 計 那 至 於 為 什 麼 做 這 個 特 別 設 計 大 家 再 去 看 一 下 原 始 文 獻 可 以 了 解 當 初 為 什 麼 會 有 這 樣 的 想 法 它 說 我 們 不 要 直 接 用 這 個 gradient descent 的 值 我 們 給 它 取 一 個 sign 這 個 sign 是 什 麼 意 思 這 個 sign 的 意 思 是 說 如 果 括 號 裡 面 的 值 大 於 0 我 們 就 輸 出 1 括 號 裡 面 的 值 小 於 0 我 們 就 輸 出 -1 所 以 加 了 sign 以 後 這 個 g 這 個 vector 啊 它 裡 面 要 嘛 是 1 要 嘛 是 -1 本 來 如 果 你 是 算 gradient 它 的 值 可 以 是 任 何 的 real number 但 現 在 取 sign 它 要 嘛 是 1 要 嘛 是 -1 所 以 g 裡 面 就 都 是 1 或 者 是 -1 然 後 learning rate 呢 learning rate 就 設 ε 就 看 你 這 邊 的 這 個 ε 設 多 大 這 邊 learning rate 直 接 設 一 個 一 模 一 樣 的 直 接 設 個 一 模 一 樣 的 會 得 到 什 麼 效 果 呢 會 告 訴 會 得 到 的 效 果 就 是 你 攻 擊 完 以 後 你 一 定 落 在 這 個 藍 色 框 框 的 四 個 角 落 的 地 方 因 為 你 想 想 看 哦 這 個 g 它 要 嘛 是 1 要 嘛 是 -1 它 每 一 維 要 嘛 是 1 要 嘛 是 -1 那 前 面 會 乘 上 ε 所 以 乘 完 ε 以 後 你 今 天 的 x0 要 嘛 就 是 往 右 邊 移 ε 要 嘛 就 是 往 左 邊 移 ε 要 嘛 就 是 往 上 移 ε 要 嘛 就 是 往 下 移 ε 所 以 今 天 做 完 一 次 攻 擊 以 後 你 的 這 個 x0 做 完 一 次 攻 擊 以 後 它 一 定 會 挪 到 這 個 四 方 形 的 四 個 角 落 的 地 方 它 一 定 是 這 四 個 角 落 的 其 中 一 個 那 光 做 這 件 事 光 做 這 個 一 擊 往 往 就 可 以 必 殺 所 以 這 個 你 可 以 過 simple baseline 那 有 同 學 就 會 問 說 一 擊 必 殺 有 什 麼 好 呢 如 果 我 多 攻 擊 幾 次 多 跑 幾 個 iteration 結 果 不 會 更 好 嗎 會 更 好 所 以 多 跑 幾 個 iteration 就 過 medium baseline 就 這 樣 子 好 所 以 怎 麼 多 跑 幾 個 iteration 你 就 把 本 來 是 只 跑 一 個 iteration 啊 現 在 就 多 跑 幾 個 iteration 啊 幾 個 iteration 你 要 跑 幾 個 iteration 高 興 都 是 你 自 己 設 就 設 個 比 如 說 3 啊 5 啊 10 啊 多 跑 幾 個 iteration 那 但 是 多 跑 幾 個 iteration 的 壞 處 是 你 有 可 能 一 不 小 心 就 出 界 有 可 能 一 不 小 心 就 跑 出 了 這 個 四 方 形 的 範 圍 那 跑 出 四 方 形 的 範 圍 後 怎 麼 處 理 呢 非 常 簡 單 把 它 拉 回 來 就 結 束 了 你 就 看 說 在 這 如 果 這 個 藍 色 的 點 update 以 後 跑 出 這 個 四 方 形 你 就 看 這 四 個 角 落 哪 一 個 角 落 跟 藍 色 的 點 最 近 就 選 那 個 角 落 就 結 束 了 好 這 個 就 是 iterative 的 fgsm 它 可 以 幫 你 過 medium 的 baseline 好 那 講 到 這 邊 呢 因 為 也 五 點 半 了 也 許 正 好 告 一 個 段 落 我 們 在 這 邊 就 先 下 課 了 那 大 家 有 問 題 呢 其 實 還 是 可 以 繼 續 留 下 來 問 那 我 們 其 實 就 到 外 面 去 討 論 好 我 們 就 下 課 了
Okay, let's talk about the next topic Let's discuss Adversarial Attack We'll cover the topic of Adversarial Attack What are we going to talk about? What we're going to discuss here is In our homework We've trained quite a lot of Various types of neural networks Of course, we hope to Apply these techniques to real-world applications But just applying these networks to real applications Implementing these networks in real applications Just their high accuracy isn't enough What more capabilities are they needing? They need to be able to manage human msalice What does malice from humans mean? Sometimes your Network Its job is to detect some malicious behaviors If its job today is to detect malicious activities The objects that it needs to detect We will try to trick the network Network under normal circumstances Getting a high accuracy rate is not enough It must function even when someone attempts to deceive it To also get a high accuracy rate. For example, we will use Network today To do E-Mail Filtering You would use the network to detect an email Is it a spam email or not As for a spam e-mail sender today He will also try his best to avoid it. His emails being classified as spam If someone today tries to change the content of the email If you want to deceive the network Can the Network not be deceived So today, we hope our neural network Its high accuracy rate is not enough We hope it can withstand the malice of humans For example, this is the ant king, do you understand? It is called Meloem It is at the top of the biology It's a pinnacle existence in biology It is extremely strong Humans can't beat it It will annihilate all humans But humans did not fight it Humans don't respect martial ethics What if humans just drop a nuclear bomb to kill it directly Then the story ended just like that Okay, so what does this tell us This tells us that For Network, high accuracy alone is not enough It must be able to deal with malice from humans Okay, next we are going to talk about human malice It could be in any form Let's first look at a real example Today, we are in many assignments We have already trained the image recognition model That is, you have an image recognition system Give it a photo It can tell us What kind of category does this photo belong to The task we're supposed to do today is Adding a very small amount of noise on this picture A photo can be seen as a very long vector We add on this very long vector Add a small amount of noise to each dimension Throw this photo with added noise into the Network Let's see what happens Usually, this noise is very, very small How small could it be It should be so small that it's invisible to the human eye So the noise added in this example is actually too large Generally, this noise is so small that the human eye can't detect it An image with added noise is called an Attacked Image Photos that have been attacked What about the photos that haven't been added to the noise yet We generally call it Benign Image It's a good image It's a picture that hasn't been attacked The Benign Image is thrown into the Network Its output is a cat We expect that the Attacked Image At this moment, we are the attackers, we are the villains We hope to throw the Attacked Image into the network Its output can't be a cat It has to become something else Well, the attacks can roughly be divided into two types One type is aimless attack An attack without a target is The original answer is cat As long as you can make the Network's output not a cat Even if you succeed But there is another harder attack It's a targeted attack. That is, we hope that the Network It's output can't be just a cat And also output something else For example, we hope that after adding noise The output of the Network is a starfish It misjudged the cat to be a starfish Only then is it considered a successful attack Okay, so could such an attack really be possible? We can actually introduce a noise that is imperceptible to the naked eye. Does it change the output of the network? Actually, it's possible The Network used here is not a weak Network It's a 50-layer ResNet When we take a benign image that hasn't been attacked When thrown into a 50-layer ResNet Its output is Tiger Cat Do you know today's image recognition system Its output will not only tell you what animal it is It will also tell you which species of animal it is So it gives this cat It not only says it's a cat It also referred to it as Tiger Cat However, it is said that this answer is actually wrong Reportedly, this cat is not a Tiger Cat But that doesn't matter Anyway, as long as it recognizes that this is a cat, that's fine At least we know it's a feline animal Okay, it also has a confidence score The confidence score is 0.64 What is the score of this confidence? This score of confidence is After finishing that Soft Mask The score received Let's say you have 2000 categories for image classification Each of the 2000 categories will have a score This score is definitely between 0 and 1 And the scores of 2000 categories added together It happens to be just 1 Given that there are 2000 categories, that's a lot. The Tiger Cat can score 0.64 Actually, that's pretty high Next, we will work on this benign image Add some noise The target we're hoping to successfully attack now It's about turning Tiger Cat into a starfish. And this is what the image looks like after being attacked You might ask, where is the noise added? The noise has been added But it's incredibly small The noise is so small that it cannot be seen by the naked eye After throwing this picture into ResNet What would happen then? The output of ResNet becomes a starfish And its confidence score is 100% Initially, it wasn't so sure whether this was a cat or not. Now it's hundred percent certain It's a starfish In order to prove There are still some differences between these two photos We subtract it Just subtracting is not enough After the subtraction is done We need to magnify their difference by 50 times You will end up with this conclusion So these two photos are indeed a bit different I did not duplicate the same photo twice to trick you They are a bit different But it's impossible for humans to detect, What kind of impact can this difference lead to? But as for ResNet Yet it has drastically different outputs Maybe some people would think Ah, maybe it's because cats and starfish have some sort of special relationship We can turn cats into starfish is just a special case This is not an exception You can easily turn this cat into anything you want I can completely add another noise Let this cat turn into a keyboard But its confidence score is as high as 0.98 Initially, I wasn't sure if it was a cat Now adding another noise The Network is 98% certain that it is a keyboard Some people might think that Hey, how could such an outrageous behavior happen Could it be this network is too poor I want to tell you, it has 50 layers. It's certainly not a terrible network. If what you add is only general noise It doesn't necessarily make mistakes This is the original picture We are now adding a piece of noise This noise is visible to the naked eye You can clearly see This picture has been added with noise At this moment, ResNet thinks What it sees is a Tabby Cat This might be the correct answer But regardless, it knows it's a feline You need to increase the noise a little more It says this is a Persian Cat Perhaps the noise can be increased a little This cat looks fluffy So ResNet thinks it sees a Persian cat The noise is boosted even more You might not know what this is At this moment, ResNet says It saw the Fire Screen What exactly is Fire Screen I googled and found out Fire Screen looks like this Here it's entirely possible to understand why the machine gets it wrong It thinks the noise in the front is this screen And this orange cat in the back is a flame Even though it makes mistakes, its mistakes have dignity The mistake it made is reasonable But for some reason When we add a noise that the human eye cannot see However, it has produced results that are worlds apart Next, let's discuss why this happened before we proceed Let's look at the attack we just mentioned How exactly was it accomplished? How on earth did we add a very small noise And this very tiny noise It can make the Network produce extremely incorrect results And this is our Network It's a function that we call f The input of this function is a picture We call it x0 Its output is a Distribution. This is the result of this classification We call it y0 So, let's assume here that the parameters of the Network are fixed We're not discussing the parameters of the Network. The parameters of the Network are not our focus today So it's fixed If it is a Non-Targeted Attack How do we find the noise of Non-Targeted Attack What we are aiming for now is We need to find a new image The new picture, we use x to represent When we input x into this Network f Its output is y And we hope that Y can match the correct answer Our correct answer is called ŷ We want the gap between y and ŷ to be as large as possible We are currently experiencing a Non-Targeted Attack Attacks without a target We just need to know the correct answer is ŷ The bigger the gap between the output of the network and the correct answer, the worse We would consider the attack successful How do we achieve this? How to find this x After throwing it into a network The greater the difference between the y it produces and ŷ, the better it is We also have to solve an optimization problem This is related to the Network we trained They're actually very similar First, let's define a Loss Function This loss function It’s called L Called L What is this L The L here represents the difference between y and ŷ Take a negative sign For example Generally when we do Classification Our training target y and ŷ Is all about its Cross Entropy Then we have `-e(y, ŷ)` This term represents the Cross Entropy between y and ŷ But we hope that this Cross Entropy will be as high as possible. So today, we're adding a negative sign in front of Cross Entropy And this negative Cross Entropy is our loss And we hope the smaller the loss, the better We are hoping to find an x x can make L(x) as small as possible The smaller L(x), it indicates that y is close to ŷ The larger their Cross Entropy, In other words, the larger the distance between y and ŷ, This is an attack without a target If it is a targeted attack We will first set our goals We use y target to represent our goal Then ŷ is actually a One-Hot Vector The y target is also a One-Hot Vector Now we hope that this y is not just better the further it is from ŷ Moreover, we want to be as close as possible to the y target So suppose your y target is a Fish You hope that the y you output, Not only should the probability of Cat be as low as possible The probability of Fish should be as high as possible. Then your Loss Function would be written like this Our loss function Is the negative of the Cross Entropy between y and ŷ The hope is that the larger this item, the better At the same time, you hope for a difference between y and y target Better be as small as possible, Add these two items together to get your Loss You hope to find an x To minimize this loss But just finding an x Minimizing Loss is not enough Because we are actually expecting The smaller the noise we add, the better Namely, the new image we found Images that can trick the Network The closer we can get to the original image, the better The closer x and x0 are, the better So when we solve this When dealing with Optimization problems We will add another limitation This limitation is d(x0,x) It is less than or equal to Σ Then d(x0,x) is less than or equal to Σ What does it mean? What it means is We hope the difference between x and x0 Less than a certain threshold Less than a certain threshold What is this threshold based on? Usually, it's determined based on human perceptual capabilities We assume if x and x0 Their difference is greater than this d(x0, x) It represents the gap between the two of them I will discuss it in the next slide How to calculate the difference between two images If the gap between x0 and x is greater than Σ We assume that people will see this noise People will notice a noise So, we want to reduce the difference between x0 and x Less than or equal to Σ It is less than or equal to the limit that humans can perceive. Then we can generate a picture To humans, x and x0 look exactly the same But its impact on the Network is They are very different Okay, so how do we measure the distance between x and x0? What's the distance between them d(x0,x) represents the distance between them There are various different algorithms. In order to facilitate the writing of equations later We suppose that x is a vector, Because it's a picture, it's a vector X0 is another picture It is also a vector We call the subtraction of these two vectors Δx And this distance You can define L2-Norm as their distance, That is, you can calculate the L2-Norm of Δx The L2-Norm of Δx is the first digit of this Δx Take it out and square it The square of the second number is taken Take the square of the third one Here, you can actually take the square root it if you want It depends on your definition of L2-Norm You are also allowed to take the square root, Well, there is another definition, which is L-Infinity How does one interpret L-infinity? It then takes this Δx And then see which dimension inside has the maximum absolute value So this one is L-Infinity Let's consider Δx1 Δx2 Δx3 That is, take the absolute value of each dimension of Δx Look at who is the largest The largest one represents the distance between x and x0 Okay, there are various methods We can calculate the distance between two pictures But which method we choose to use When it comes to calculating the distance of the image In fact, we should take human perception into consideration So, between L2 and L-Infinity, which one It's a better distance when attacking Next, I'll provide an example to explain Alright, this is a picture. Assume this picture only has four Pixels Right now We make two different changes to this picture The first change was the color of these four Pixels There have been very small changes The second change involves only the pixel at the bottom right corner Its color has been changed And the changes are bigger If we are calculating the L2 Norm today The L2-Norm of these two images Has the same L2-Norm as these two pictures The picture above is the picture below The result after all four pixels have been modified The picture in the middle above is the picture below The image below is the image in the middle Only the pixel in the bottom right corner changes the result after its adjustment, The change here is relatively significant The L2 Norm of these two changes is the same But if you look at L-Infinity They are different Because L-Infinity is only concerned with the maximum amount of change As for L-Infinity, The maximum change in this Adjusting it to its maximum variation The maximum change made to the item below is larger The significant change on the top is rather small Then, if we take this example, there are differences between L-Infinity and L2. Which one is closer to human's perception ability Maybe it should be L-Infinity Because for you Actually, these two images I believe most of you probably wouldn't be able to tell What's the difference between them I assure you, there's a difference between them They have very, very slight differences The only difference is that it is distributed on every Pixel And the changes in these two below You can clearly see the green color in the lower right corner Its color has deepened Although the colors of the other three pixels are fixed The color of lower-right corner gets darker Then you'll notice changes in the photos Then it was found that this picture has achieved it Some modifications have been made So it seems that L-Infinity might better meet the actual needs We want to avoid being humans We should avoid being detected by humans Just being small in L2 is not enough We should make L-Infinity smaller This is less likely to be noticed So, in our assignment, we use L-Infinity Let's use this as our limitation To use as an attack So our task is to attack one The one on JudgeBoi Like the image generated by the recognition system We will have certain limitations The new image and the old image The difference from the original Benign Image It needs to be below a certain threshold When we define this difference Therefore, we choose L-Infinity How should we define this gap in reality for it to be better You still need domain knowledge The example we just gave was an image-based example If our target of attack today It's actually a system related to speech Our 'x' and 'x0' are actually audio signals What kind of sound signals It sounds different to humans Then it might not necessarily be L2 and L-Infinity You should study the human auditory system Let's see what frequency changes humans are particularly sensitive to Then, based on the human auditory system to establish A more suitable way to measure the distance between x and x0 This section requires the use of Domain Knowledge. Okay, now we already have it. Our problem with Optimization What we need to do is We need to minimize the loss. Now we need to find an x to minimize this Loss. But there are limitations to this x The distance between x and x0 should be less than or equal to x So, how do we solve this problem Let's first remove this restriction If we remove this restriction Do you know how to solve this problem? You would actually solve this problem Because this is not much different from us training a model, In our first lesson Here, I've shown you this optimization problem Tell you that you can adjust the parameters of your Network To minimize the Loss Today, we're just changing the parameters. Simply the Input of the Network Just like that You take that Image as an Input Consider it as a part of the network parameters Then, you minimize your loss function and you're done The parameters of the network are now fixed We only adjust the input part Let the Input part change End when reaching the minimum loss We're still using the Gradient Descent method How to do it? Just do it this way First, you need to have an initialization The thing we're looking for now is not the Network Parameters it is x It's the Image you input But it still needs an initialization value, right? You still need one. The value initialized when doing Gradient Descent What is a good value for the initial setting? You may not start from a random image You may start from x0 Because we originally hoped that The new 'x' we find should be as close to 'x0' as possible Then why don't you start looking from x0? You start looking from x0 The 'x' you find next might be closer to 'x0' So the x you initialized The x0 you initialize would just be directly set as x0 Then what follows is A regular Gradient Descent is exactly the same We are iteratively updating your parameters Set an Iteration t equals 1 to T. Then in each Iteration You will calculate the gradient But this Gradient is not a parameter of the Network The Gradient of the Loss We no longer care about the Network parameters It is not the Image x in the Input Regarding the gradient of the loss Then this x as Input It's also a very long vector It contains x1, x2, x3, etc. You simply compute within this input image. The partial derivative of each value with respect to L. That is, the partial derivative of x1 with respect to L Partial derivative of x2 with respect to L Calculated Calculate a gradient Using this Gradient The update of your image is finished So your original Image x0 It just subtracts this Gradient You would also multiply a learning rate in the front, It's exactly the same as general Gradient Descent It's just the target of gradient descent. Just change from parameters to input Everything else is the same There are also things like Learning Rate and everything Multiply by a Gradient Multiply by the Learning Rate Subtracting the original Image And then get a new image You can run it iteratively It is just like the usual Gradient Descent But this is under the premise of no constraints Next, we need to add the Constraint Because usually when we do gradient descent We did not take that What restrictions are placed on the target of Gradient Descent? We did not set a limit to say that What should our parameters look like We are now limited We restrict x and x0 Their difference must be less than or equal to ε So how do we deal with this problem? You have it in your Gradient Descent Add another module Uh, I just noticed it's already 5:20 Today we need to end around 5:20 So, we might need something later When a paragraph is reached, it ends just like that Okay, we need to run the Gradient Descent algorithm But we need to consider the difference between x0 and x How should we consider this matter? Over here This method is not really worth it when you get down to it It's incredibly simple If you notice x0 and X after you've updated your parameters I should use xt here to be accurate I should use xt here to be more accurate You find that after you've updated your parameters When the gap between your xt and x0 is greater than ε You just make a modification Modify xt Once it's amended to meet the constraints, it's done For instance Assume we're currently using L-Infinity Our x0 is here The range where our x can exist There's only this square range, right? Because L-Infinity considers the maximum difference between x0 and x So the gap outside this framework will exceed ε So today after you have completed this Gradient Descent After updating your x with the Gradient It must still fall within this frame How can we ensure that after the Update It must fall into this frame. You will When the update exceeds the box Just pull it back and it's over So if you complete this step today What if you find that the blue dot has run out of the box? Find the closest position to the blue dot in the box The process ends once you pull the blue dot in. It's over Well, in fact, this type of attack has many different variations I think you can find it in the literature Various methods of Attack But in essence, they are not far apart The thing we are talking about today The differences are usually Either the Constraint is different Either the method of Optimization is different But usually, we still use Gradient Descent Their spirit remains the same It's just that you may have different Optimizers here Here, you may encounter different constraints Then it becomes a different attack method But their spirit is not lost The example we bring up today Okay, what comes next Let us introduce to you the simplest method of Attack And it's also one you need to get through in your homework This should be the method used by Medium Baseline So what is this method? This method is called FGSM Can it pass the Medium Baseline Oh, it can't exceed the medium baseline It can only get through Simple Baseline Okay, how does this FGSM work It's very simple It's called Fast Gradient Sign Method, abbreviated How does it do that It's like a one-punch man It only takes one hit Usually, when you do gradient descent You need to update the parameters multiple times But the brilliance of FGSM is It decides to only update parameters once Let's see if we can kill in one strike Find an image that can be successfully attacked with one strike So, first of all, Originally, we were supposed to update the parameters iteratively But now there's no need We only perform the attack once We only do one Attack And about G this side... It has a special design As for why this special design is done Let's refer back to the original literature You can understand why such a concept was proposed in the first place It says we should not use this directly The value of Gradient Descent We take a sign for it What does this sign mean? The meaning of this sign is If the value inside the parenthesis is greater than 0 We then output 1 If the value in the parenthesis is less than zero We output -1 So, after adding the Sign This vector g, It could be either 1 or -1 inside Originally, if you are calculating the gradient, Its value can be any real number But now we take the sign It is either 1 or -1 Therefore, all the values in g are either 1 or -1. Then what about the Learning Rate Set the learning rate to ε It depends on how large you set this ε here The learning rate here is set the same directly What effect would setting an identical one directly have? Will tell you The effect we will get is After your attack, You must land in the four corners of this blue box Because if you think about it This 'G' can either be 1 or -1 Each of its dimensions is either 1 or -1 The value in front is multiplied by ε So after multiplying by ε Your x0 today Or move to the right by ε Or move to the left by ε Either move up by ε Either move down by ε So after completing an attack once After completing one attack with your X0 It will certainly move to the corners of this square, It has to be one of the four corners Just doing this alone A single strike often suffices for a kill So you can go over the Simple Baseline Then some students would ask about the benefit of one-shot kills. If I attack a few more times Would running more iterations produce better results? It would be better So run a few more Iterations Just go through Medium Baseline like this Alright, so how to run more iterations You just do what would have been done in one iteration Just run a few more iterations now Several iterations How many Iterations do you need to run Happiness is what you set for yourself Let's set it to 3, 5, or 10 for example Run a few more Iterations However, the downside of running more iterations is... You could possibly step out of bounds accidentally It's possible to accidentally step out of this square range. So, how do we handle it when we step out of the square range? It's very simple Pull it back and it's done You see, this is where After the blue point is updated Square shapes are formed Just look at these four corners Which corner is the closest to the blue dot Just choose that corner And it’s over. Alright, this is the iterative FGSM It can help you pass Medium's Baseline Okay, let's stop here Because it's already five-thirty Perhaps to tell a paragraph We’ll end the class here Does anyone have a question? In fact, you can continue to stay and ask Then, let's take the discussion outside. Okay, class is dismissed
week10_4.wav
"好 那 上 週 呢 我 們 是 講 到 這 個 地 方 好 那 到 目 前 為 止 啊 我 們 在(...TRUNCATED)
"Alright, so last week, we left off here Okay, so far The content we discussed in class is actually (...TRUNCATED)
week11_1.wav
"好 我 們 現 在 要 來 講 explainable 的 machine learning 到 目 前 為 止 我 們 已 (...TRUNCATED)
"Okay, now we are going to discuss Explainable Machine Learning Up to this point We have trained a l(...TRUNCATED)
week11_2.wav
"好 那 我 們 來 上 課 了 那 我 們 接 下 來 呢 要 講 global 的 explanation 那 glob(...TRUNCATED)
"Okay, let's start the class So, what's next We will discuss Global Explanation So, what does Global(...TRUNCATED)
week13_1.wav
"好 那 個 講 完 domain adaptation 以 後 我 們 就 稍 微 休 息 一 下 然 後 下 一 (...TRUNCATED)
"Okay, after finishing the topic on Domain Adaptation We'll take a brief break Then, the next part w(...TRUNCATED)
week13_2.wav
"好 那 我 們 來 上 課 吧 那 這 一 堂 課 啊 我 們 要 講 的 是 deep reinforcement (...TRUNCATED)
"Okay, let's start class So for this lesson What we will discuss is Deep Reinforcement Learning Whic(...TRUNCATED)
week13_3.wav
"好 我 們 就 繼 續 來 上 課 吧 好 感 謝 各 位 同 學 提 到 有 關 關 麥 的 問(...TRUNCATED)
"Alright, let's continue with the class. Okay. I thank all students for bringing up the issue about (...TRUNCATED)
week13_4.wav
"好 那 我 們 就 開 始 上 課 吧 那 等 一 下 的 規 劃 是 這 樣 我 們 先 把 rl (...TRUNCATED)
"Alright, let's begin the class. Here's what we are going to do next. First, let's wrap up the RL to(...TRUNCATED)
week15_1.wav

Derived from: ky552/ML2021_ASR_ST Segments from the same lecture are concatenated together.

Downloads last month
4
Edit dataset card