---
title: 【DL輪読会】Deep Transformers without Shortcuts: Modifying Self-attention for Faithful Signal Propagation
tags:  #@deep learning jp  
author: [Deep Learning JP](https://www.docswell.com/user/DeepLearning2023)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/P7R2Q53WJ9.jpg?width=480
description: 2023/6/23 Deep Learning JP http://deeplearning.jp/seminar-2/
published: June 23, 23
canonical: https://www.docswell.com/s/DeepLearning2023/ZW13NY-dldeep-transformers-without-shortcuts-modifying-selfattention-for-faithful-signal-propagation
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/P7R2Q53WJ9.jpg)

Deep Transformers without Shortcuts:
Modifying Self-attention for Faithful Signal Propagation
Shohei Taniguchi, Matsuo Lab
1


# Page. 2

![Page Image](https://bcdn.docswell.com/page/PJXD5K4VEX.jpg)

Deep Transformers without Shortcuts
ॻࢽ৘ใ
ஶऀ
• Bobby He, James Martens, Guodong Zhang, Aleksandar Botev, Andrew Brock,
Samuel L Smith, Yee Whye Teh (DeepMind)
֓ཁ
• TransformerΛlayer normalization΍skip connectionͳ͠ͰֶशͰ͖ΔΑ͏ʹվྑ
• ICLR 2023 accepted
2


# Page. 3

![Page Image](https://bcdn.docswell.com/page/3JKX65Z5ED.jpg)

ൃද֓ཁ
• എ‫ܠ‬
• ؔ࿈‫ڀݚ‬
• ख๏
• ࣮‫݁ݧ‬Ռ
• ·ͱΊ
3


# Page. 4

![Page Image](https://bcdn.docswell.com/page/LE356KD1J5.jpg)

എ‫ܠ‬
Transformer
• Transformer͸AttentionͱMLPͷ‫܁‬Γฦ͠
• ֤ϞδϡʔϧͰskip connectionͱlayer normalizationΛ
ద༻͢Δͷ͕Ұൠత
• ͜ΕΒ͕࣮ࡍʹͲ͏͍͏໾ׂΛՌ͍ͨͯ͠Δ͔͸
‫ݱ‬ঢ়ෆ໌
• ͏·ֶ͘श͢ΔͨΊͷςΫχοΫͱ͍͏Ґஔ෇͚
4


# Page. 5

![Page Image](https://bcdn.docswell.com/page/8EDDV3PKEG.jpg)

ؔ࿈‫ڀݚ‬
Normalization-free Network
• MLP΍CNNͰ͸ɼskip connection΍ਖ਼‫ن‬Խ͕ͳͯ͘΋ਂ͍ωοτϫʔΫΛֶश
Ͱ͖Δํ๏͕஌ΒΕ͍ͯΔ
• ‫ج‬ຊతʹ͸ɼޯ഑ফࣦ/രൃ͕‫͜ى‬Βͳ͍Α͏ʹద੾ʹॏΈͷॳ‫ظ‬ԽΛߦ͑͹
ਖ਼‫ن‬ԽͳͲΛ࢖Θͳͯ͘΋େৎ෉
• Dynamic isometryͱ͍͏֓೦͕ಛʹॏཁ
5


# Page. 6

![Page Image](https://bcdn.docswell.com/page/V7PXV4N3E8.jpg)

Isometry
౳ํੑ
L૚ͷMLPΛߟ͑Δͱɼೖྗ͔Βग़ྗ΁ͷϠίϏߦྻJ͸ɼ֤૚ͷॏΈͷߦྻੵ
x = ϕ (h ), h = W x
l
l
l
l l−1
L
L
∂x
l l
J= 0 =
DW
∏
∂h
l=1
l
ͨͩ͠ɼD ͸Dij
=
l
ϕ′ (hi ) δijΛຬͨ͢ର֯ߦྻ
￼
l
6
l
+b


# Page. 7

![Page Image](https://bcdn.docswell.com/page/2JVLZXKN7Q.jpg)

􁉃
Isometry
౳ํੑ
L
L
∂x
l l
J= 0 =
DW
∏
∂h
l=1
• ͜ͷϠίϏߦྻ͕ফࣦ/രൃ͍ͯ͠ͳ͚Ε͹ɼ҆ఆֶͯ͠शͰ͖Δ͸ͣ
ߦྻͷಛҟ஋͕1෇ۙʹͳ͍ͬͯΕ͹ྑ͍
l
• W ͷಛҟ஋ͷฏ‫͕ۉ‬1ͷͱ͖ɼ౳ํੑΛຬͨ͢
l
• D ʹ͍ͭͯ͸ɼ‫׆‬ੑԽؔ਺͕‫߃Ͱۙ෇఺ݪ‬౳ؔ਺ͳΒ౳ํతʢtanhͳͲʣ
7


# Page. 8

![Page Image](https://bcdn.docswell.com/page/5EGX4VQ5JL.jpg)

􁉃
Dynamic Isometry
ಈత౳ํੑ
L
L
∂x
l l
J= 0 =
DW
∏
∂h
l=1
• ͞Βʹɼ͢΂ͯͷಛҟ஋͕1ͷͱ͖ɼಈత౳ํੑΛຬͨ͢
• ͜ΕΛຬͨ͢ͷ͸ɼॏΈ͕௚ަߦྻͷͱ͖
௚ަॳ‫ظ‬ԽΛ͢Ε͹ɼޯ഑ফࣦ/രൃ͠ͳ͍ʂ
8


# Page. 9

![Page Image](https://bcdn.docswell.com/page/4JQ8G6KL7P.jpg)

ؔ࿈‫[ ڀݚ‬1]
• MLPͰCIFAR-10ͷ෼ྨ
• ௚ަॳ‫ظ‬Խ + tanh͸ଞΑΓ଎͘ऩଋ͢Δ
9


# Page. 10

![Page Image](https://bcdn.docswell.com/page/K74254P5J1.jpg)

ؔ࿈‫[ ڀݚ‬2]
CNNͷ৔߹
• CNN΋ಈత౳ํੑΛຬͨ͢Α͏ʹॳ‫ظ‬Խ͢Ε͹ɼਂ͍ϞσϧΛਖ਼‫ن‬Խͳ͠Ͱ
ֶशՄೳ
• ৞ΈࠐΈΧʔωϧͷதԝͷΈΛ௚ަॳ‫ظ‬Խͯ͠ɼ࢒Γ͸͢΂ͯ0Ͱॳ‫ظ‬Խ
• 1x1 convΛ௚ަॳ‫ظ‬Խͯ͠ɼͦͷपΓΛ0ຒΊ͢Δ‫ܗ‬
• ৞ΈࠐΈॲཧશମΛߦྻԋࢉͱ‫ʹ͖ͱͨݟ‬΋௚ަߦྻʹͳΔ
10


# Page. 11

![Page Image](https://bcdn.docswell.com/page/LJ1MW492EG.jpg)

ؔ࿈‫[ ڀݚ‬2]
CNNͷ৔߹
• MNISTΛ4,000૚ͷCNNͰֶश
• ਖ਼‫ن‬Խ΍skip connection͸ೖΕͳ͍
• ਖ਼‫ن‬෼෍Ͱॳ‫ظ‬Խ͢ΔΑΓ΋ֶश͕଎͘ͳΔ
11


# Page. 12

![Page Image](https://bcdn.docswell.com/page/GJW36XQ2J2.jpg)

􁉃
ؔ࿈‫[ ڀݚ‬2]
CNNͷ৔߹
• MNISTͱCIFAR-10Ͱ༷ʑͳਂ͞ͷϞσϧΛֶश
• 10,000૚·Ͱ૿΍ͯ͠΋ֶशͰ͖Δ
• ͨͩ͠ɼCIFAR-10Ͱ͸ςετͷਫ਼౓͕ανΔ
ਖ਼‫ن‬Խ΍skip connection͸ֶशͷ҆ఆԽΑΓ΋
൚Խʹ‫د‬༩͍ͯ͠Δ͜ͱΛࣔࠦ
12


# Page. 13

![Page Image](https://bcdn.docswell.com/page/4EZVY6W4J3.jpg)

ؔ࿈‫[ ڀݚ‬3]
ReZero
• Skip connectionΛೖΕΔ৔߹Ͱ΋ɼಈత౳ํੑΛຬͨ͢Α͏ʹ
ॳ‫ظ‬Խ͢Ε͹ɼ͞ΒʹੑೳΛ্͛ΒΕͦ͏
xi+1 = xi + αiF (xi)
• ௨ৗ͸ αi = 1 ʹ͢Δ͕ɼαi = 0 Ͱॳ‫ظ‬Խͯ͠αi΋ֶशύϥϝʔλʹ͢Δ
• ॳ‫ظ‬Խ࣌఺Ͱ͸ɼxi+1 = xi ͳͷͰɼ໌Β͔ʹಈత౳ํੑΛຬͨ͢
13


# Page. 14

![Page Image](https://bcdn.docswell.com/page/Y765D2GGEV.jpg)

ؔ࿈‫[ ڀݚ‬3]
ReZero
• CIFAR-10Ͱ32૚ͷMLPΛֶश
• ਖ਼‫ن‬Խͳ͠Ͱ΋͔ͳΓֶश͕଎͘ͳΔ
14


# Page. 15

![Page Image](https://bcdn.docswell.com/page/G75Y32VX74.jpg)

ؔ࿈‫[ ڀݚ‬3]
ReZero
• CIFAR-10ͰResNetΛֶश
• ֶश͕଎͘ͳΓɼੑೳ΋্͕Δ
15


# Page. 16

![Page Image](https://bcdn.docswell.com/page/9J2GZ43QJR.jpg)

ؔ࿈‫[ ڀݚ‬4]
ReLUͷ৔߹
• ReLUͷ৔߹͸ɼ௚ަॏΈͷҰ෦Λ൓సͤ͞Ε͹ಈత౳ํੑΛຬͨͤΔ
• ௚‫ײ‬తʹ͸ɼReLUͰ͸ෛͷ஋ʹͳͬͨೖྗ৴߸͕͢΂ͯ0ʹःஅ͞ΕΔͷͰɼ
ͦΕΛଧͪফ͢Α͏ʹූ߸Λ൓సͤ͞Ε͹ྑ͍ͱ͍͏͜ͱ
16


# Page. 17

![Page Image](https://bcdn.docswell.com/page/DEYVRM1YEM.jpg)

ؔ࿈‫[ ڀݚ‬5]
Transformerͷrank collapse
• MLP, skip connection, LayerNormͷͳ͍
attentionͷΈͷTransformer͸ɼॳ‫ظ‬Խͷ
࣌఺ͰϞσϧશମͷߦྻ͕૚਺ʹରͯ͠
ࢦ਺తʹϥϯΫམͪ͢Δ͜ͱ͕ཧ࿦తʹ
΋ࣔͤΔ
• AttentionͷΈͰ͸Transformer͸ֶशͰ͖
ͳ͍͜ͱΛࣔࠦ
17


# Page. 18

![Page Image](https://bcdn.docswell.com/page/VJNMDW2R78.jpg)

􁉃
Deep Transformers without Shortcuts
• TransformerͰ΋ਖ਼‫ن‬Խ΍skip connectionͳ͠ͰֶशͰ͖Δʁ
‫ؤ‬ுΕ͹Ͱ͖Δ
• ७ਮʹਖ਼‫ن‬ԽͱskipΛൈ͘ͱޯ഑͕
രൃ͢Δ
• ఏҊ๏͸͍ͩͿ཈͑ΒΕ͍ͯΔ


# Page. 19

![Page Image](https://bcdn.docswell.com/page/YE9NGX1ZE3.jpg)

Deep Transformers without Shortcuts
Γ͸े෼େ͖͍ఆ਺
Attn(X) = A(X)V(X)
A(X) = softmax M ∘
(
1
k
d
⊤
Q(X)K(X) − Γ(1 − M)
)
• ຊ࿦จͰ͸ɼGPT‫࢖Ͱܥ‬ΘΕΔΑ͏ͳCausal masked attentionΛର৅ʹ͢Δ
• ະདྷͷ‫ྻܥ‬Λࢀর͠ͳ͍Α͏ʹMi,j = 1i≥jͰϚεΫ͢Δ


# Page. 20

![Page Image](https://bcdn.docswell.com/page/LELZ52V9JR.jpg)

Deep Transformers without Shortcuts
• ·ͣ͸ɼMLPͷͳ͍attention-onlyͷϞσϧΛߟ͑ΔͱɼL૚໨ͷಛ௃ྔ͸
XL = [ALAL−1…A1] X0W, W =
• Σl =
⊤
XlXl ,
L
V O
Wl Wl
∏
l=1
Πl = AlAl−1…A1ͱ͓͘ͱɼW͕௚ަߦྻͷͱ͖
Σl = Πl ⋅ Σ0 ⋅
⊤
Πl


# Page. 21

![Page Image](https://bcdn.docswell.com/page/4JMV38GVJW.jpg)

􁉃
Deep Transformers without Shortcuts
• Σl =
⊤
XlXl ,
Πl = AlAl−1…A1ͱ͓͘ͱɼW͕௚ަߦྻͷͱ͖
Σl = Πl ⋅ Σ0 ⋅
⊤
Πl
• Σl͕୯Ґߦྻʹ͚ۙΕ͹ɼޯ഑͕҆ఆ͢Δ
ͦΕ͕‫͜ى‬ΔΑ͏ʹAlΛઃ‫͍ͨ͠ܭ‬
• ͨͩ͠ɼAl͸ཁૉ͕ඇෛͷԼࡾ֯ߦྻͱ͍͏੍໿෇͖


# Page. 22

![Page Image](https://bcdn.docswell.com/page/PJR2Q5ZWE9.jpg)

􁉃
Deep Transformers without Shortcuts
• Al =
⊤
−1
−1
−1
LlLl−1ͱ͓͘ͱɼL0 Σ0L0
= IT͕੒Γཱͭ΋ͱͰ
Σl =
⊤
LlLl
• ͜Ε͸ίϨεΩʔ෼ղʹ૬౰͢Δ
ଥ౰ͳΣlΛઃ‫ͯ͠ܭ‬ɼͦͷίϨεΩʔ෼ղLlΛ‫ٻ‬ΊΕ͹ɼ৚݅Λຬͨ͢AlΛ
࡞ΕΔ


# Page. 23

![Page Image](https://bcdn.docswell.com/page/PEXD5K9V7X.jpg)

Deep Transformers without Shortcuts
U-SPA
Σl (ρl) = (1 − ρl) IT + ρl11
⊤
• ର֯੒෼͕1ͰͦΕҎ֎͕ρlͷߦྻ
• 0 ≤ ρ0 ≤ ρ1 ≤ ⋯ ≤ ρL &lt; 1Λຬͨͤ͹ɼ৚݅Λຬͨ͢
• ϥϯΫམͪ΋๷͛Δ


# Page. 24

![Page Image](https://bcdn.docswell.com/page/3EKX65P57D.jpg)

Deep Transformers without Shortcuts
E-SPA
|
|
Σ
γ
=
exp
−γ
i
−
j
(
)
(
)
l
l
l
(
)
i,j
• ର֯੒෼͕1ͰͦΕҎ֎͸ର֯ઢ͔Βͷ‫Ͱ཭ڑ‬஋͕ఆ·Δߦྻ
• γ0 ≥ γ1 ≥ ⋯ ≥ γL &gt; 0Λຬͨͤ͹ɼ৚݅Λຬͨ͢
• ϥϯΫམͪ΋๷͛Δ


# Page. 25

![Page Image](https://bcdn.docswell.com/page/L7356KX1E5.jpg)

Deep Transformers without Shortcuts
Attentionͷ࠶ఆٛ
• લड़ͷΣ͔Β‫ͨͬ࡞ͯ͠ࢉٯ‬AΛɼA = DPͱ෼ղ
• D͸ਖ਼ͷର֯ߦྻɼP͸֤ߦͷ࿨͕1ͷԼࡾ֯ߦྻ
• B = log(P)ͱ͓͍ͯɼҎԼͷΑ͏ʹattentionΛ࠶ఆٛ
Q
• Q(X)ͷॏΈW Λ0Ͱॳ‫ظ‬Խ͢Δ͜ͱͰɼॳ‫ظ‬஋ʹ͓͍ͯΣ͕ॴ๬ͷ‫ͳʹܗ‬Δ
Attn(X) = DP(X)V(X), P(X) = softmax M ∘
[
Q(X)K(X) + B − Γ(1 − M)
]
dk
1
⊤


# Page. 26

![Page Image](https://bcdn.docswell.com/page/87DDV32K7G.jpg)

࣮‫ݧ‬
WikiText-103
• 36૚ͷTransformerΛֶश
• ૉ๿ʹskipΛͳͨ͘͠΋ͷ͸ɼશֶ͘शͰ͖ͳ͍
• ఏҊ๏͸ɼͪΌΜͱֶशͰ͖ͯΔ
• ͨͩ͠ɼskip + LNΛೖΕͨ௨ৗͷ΋ͷΑΓ΋
ֶश͕͍ͩͿ஗͍


# Page. 27

![Page Image](https://bcdn.docswell.com/page/VJPXV41378.jpg)

࣮‫ݧ‬
C4σʔληοτ
• 32૚ͷTransformerΛֶश
• ֶश࣌ؒΛ৳͹ͤ͹ɼskip + LN͋Γͷੑೳʹ౸ୡ͢Δ
• ໿5ഒ͘Β͍͕͔͔࣌ؒΔ
• Transformerʹ͓͍ͯ͸ɼskip΍LN͸ֶशͷ
ߴ଎Խʹ‫د‬༩͍ͯ͠Δʁ


# Page. 28

![Page Image](https://bcdn.docswell.com/page/2EVLZXYNJQ.jpg)

࣮‫ݧ‬
C4σʔληοτͰͷ࣮‫ݧ‬
• Skip connectionΛೖΕΔͱఏҊ๏͕ϕʔεϥΠϯͷskip + LNͷ΋ͷʹউͭ
• ΍͸ΓTransformerͰ͸skip connection͕
௒ॏཁʁ


# Page. 29

![Page Image](https://bcdn.docswell.com/page/57GX4V95EL.jpg)

·ͱΊ
• MLP΍CNNͰ͸ɼಈత౳ํੑΛຬͨ͢Α͏ʹॳ‫ظ‬ԽΛߦ͑͹ɼਖ਼‫ن‬Խ΍skip
connectionͳ͠Ͱ΋ɼਂ͍ωοτϫʔΫΛֶशͰ͖Δ
• TransformerͰ΋ɼಉ͡Α͏ʹॳ‫ظ‬ԽΛஸೡʹ΍Ε͹ɼskip΍LNͳ͠ͰֶशͰ
͖Δ͜ͱ͕Θ͔ͬͨ
• ͨͩ͠ɼֶश͕͔࣌ؒͳΓ͔͔Δ


# Page. 30

![Page Image](https://bcdn.docswell.com/page/4EQ8G6WLJP.jpg)

‫ײ‬૝
• ए‫ׯ‬ແཧ΍Γ‫ײ‬͸൱Ίͳ͍
• ݁‫ظॳہ‬Խ࣌ͷattention͕୯Ґߦྻʹۙ͘ͳΔΑ͏ʹ͢Ε͹ྑ͍ͱ͍͏͜ͱ
ͷ͸ͣ
• ΋ͬͱγϯϓϧͳํ๏΋͋Γͦ͏ͳ‫͕͢ؾ‬Δ
• ֶश͕஗͘ͳΔ‫ݪ‬Ҽ͕Ͳ͜ʹ͋Δͷ͔͕͋·ΓΘ͔͍ͬͯͳ͍


# Page. 31

![Page Image](https://bcdn.docswell.com/page/KJ4254K5E1.jpg)

ࢀߟจ‫ݙ‬
[1] Pennington, Jeffrey, Samuel Schoenholz, and Surya Ganguli. &quot;Resurrecting the
sigmoid in deep learning through dynamical isometry: theory and practice.&quot;
Advances in neural information processing systems 30 (2017).
[2] Xiao, Lechao, et al. &quot;Dynamical isometry and a mean field theory of cnns: How to
train 10,000-layer vanilla convolutional neural networks.&quot; International Conference
on Machine Learning. PMLR, 2018.
[3] Bachlechner, Thomas, et al. &quot;Rezero is all you need: Fast convergence at large
depth.&quot; Uncertainty in Artificial Intelligence. PMLR, 2021.
31
APA


# Page. 32

![Page Image](https://bcdn.docswell.com/page/LE1MW4X27G.jpg)

ࢀߟจ‫ݙ‬
[4] Burkholz, Rebekka, and Alina Dubatovka. &quot;Initialization of relus for dynamical
isometry.&quot; Advances in Neural Information Processing Systems 32 (2019).
[5] Dong, Yihe, Jean-Baptiste Cordonnier, and Andreas Loukas. &quot;Attention is not all
you need: Pure attention loses rank doubly exponentially with depth.&quot; International
Conference on Machine Learning. PMLR, 2021.
[6] He, Bobby, et al. &quot;Deep Transformers without Shortcuts: Modifying Self-attention
for Faithful Signal Propagation.&quot; The Eleventh International Conference on Learning
Representations. 2023.
32


