-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add FNet #1499
Add FNet #1499
Conversation
预训练模型位置1.spiece.model
2.model_state.pdparams |
@HJHGJGHHG 感谢贡献,麻烦签署一下CLA哈 #1499 (comment) |
多谢提醒,已签署。
…------------------ 原始邮件 ------------------
发件人: "PaddlePaddle/PaddleNLP" ***@***.***>;
发送时间: 2021年12月23日(星期四) 晚上10:06
***@***.***>;
***@***.******@***.***>;
主题: Re: [PaddlePaddle/PaddleNLP] Add FNet (PR #1499)
@HJHGJGHHG 感谢贡献,麻烦签署一下CLA哈 #1499 (comment)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@@ -0,0 +1,871 @@ | |||
# encoding=utf8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paddlenlp 仅支持python3.6+,不需要指定编码。可以删去
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已删除
return x * F.sigmoid(x) | ||
|
||
|
||
def gelu_new(x): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个GELU实现和paddle.nn.funtional.gelu()
实现有什么不同?
paddle.nn.funtional.gelu()
是否可以满足需求?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是paddle.nn.funtional.gelu()在approximate=True时的版本。由于不好指定关键字参数所以此处单独列出,其他模型(如albert)也如此。后续可将paddle.nn.funtional.gelu()拆成两部分,更为精简。
intermediate_output = self.intermediate(fourier_output) | ||
layer_output = self.output(intermediate_output, fourier_output) | ||
|
||
return (layer_output,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只有一个返回值,可以不需要使用tuple
return {"last_hidden_state": hidden_states, | ||
"all_hidden_states": all_hidden_states | ||
} | ||
return (hidden_states,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
|
||
def forward(self, hidden_states): | ||
outputs = self.fourier_transform(hidden_states).real() | ||
return (outputs,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
def forward(self, hidden_states): | ||
self_outputs = self.fourier_transform(hidden_states) | ||
fourier_output = self.output(self_outputs[0], hidden_states) | ||
return (fourier_output,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
@@ -0,0 +1,291 @@ | |||
# encoding=utf8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删去指定编码
def __init__(self): | ||
super().__init__() | ||
# self.fourier_transform = paddle.fft.fftn | ||
self.fourier_transform = partial(paddle.fft.fftn, axes=(1, 2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paddle.fft.fftn()
不建议用partial
封装,使用partial
封装会可能导致出错堆栈信息复杂。直接调用即可。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
@@ -0,0 +1,871 @@ | |||
# encoding=utf8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已删除
return x * F.sigmoid(x) | ||
|
||
|
||
def gelu_new(x): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是paddle.nn.funtional.gelu()在approximate=True时的版本。由于不好指定关键字参数所以此处单独列出,其他模型(如albert)也如此。后续可将paddle.nn.funtional.gelu()拆成两部分,更为精简。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
参考其他模型给modeling.py和tokenizer.py这两个文件添加docstrings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已添加docstring
可以提供百度网盘或者google_drive下载链接吗~ |
我重新上传一下~~ |
已上传至百度网盘 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR types
PR changes
Description
添加FNet模型文件