Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transformer.py 中的forword方法调用的SublayerConnection类。实现残差链接和标准化的实现 #83

Open
dshwei opened this issue Sep 23, 2020 · 1 comment

Comments

@dshwei
Copy link

dshwei commented Sep 23, 2020

sublayerout = layerNorm(x +sublayer(x))
首先是残差链接然后是层标准化
在你代码中:sublayer.py中 应该是
def forward(self, x, sublayer):
"Apply residual connection to any sublayer with the same size."
# return x + self.dropout(sublayer(self.norm(x)))
return self.norm( x + self.dropout(sublayer(x)))

tranformer.py中:
def forward(self, x, mask):
x = self.input_sublayer(x, lambda _x: self.attention.forward(_x, _x, _x, mask=mask))
x = self.output_sublayer(x, lambda _x: self.feed_forward.forward(_x))
return self.dropout(x)

此处我对论文立即额和你不一样,有错误的地方请指教

@Bowen-n
Copy link

Bowen-n commented Oct 16, 2020

The transformer implementation is the same as The Annotated Transformer.

In sublayer.py, there is a comment Note for code simplicity the norm is first as opposed to last.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants