mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[GH-ISSUE #91] Layer Norm before Residual #82
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#82
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @skull8888888 on GitHub (Apr 10, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/91
Hello, I noticed that on line 186 in
model.pyyou putlayer normbeforeMultiHeadAttentionand Residual, as opposed to putting Layer Norm after Residual as described in the original Transformer paper.In my research I found this paper which argues that such configuration improves convergence and removes the need for careful warmup.
In my experiment when I used your implementation of Transformer Block for seq2seq model 1 layer works pretty nice, however when I stuck 2 layers performance significantly degrades.
So my questions are: What is the reasoning behind it? And how to make it work with stacked layers?
@jongwook commented on GitHub (Apr 21, 2021):
The linked paper shows some reasoning behind using normalizations in the residual branch as opposed to the main trunk. One intuition is that keeping an identity mapping flow helps stabilize the training, as suggested by He et al. (2016), as opposed to going through multiple layer normalization ops proportional to the depth. This approach is adopted in most of OpenAI models since GPT-2, as outlined in page 4, column 2 of the GPT-2 paper and Figure 8d of the Jukebox paper.
As for your 1-layer vs 2-layer results, I can't say anything definite because it's not a precise science in the first place, and your mileage may vary vastly depending on various factors such as model architecture, training hyperparameters, datasets, etc.