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

Add FNet #1499

Merged
merged 22 commits into from
Jan 11, 2022
Merged

Add FNet #1499

merged 22 commits into from
Jan 11, 2022

Conversation

HJHGJGHHG
Copy link
Contributor

PR types

PR changes

Description

添加FNet模型文件

@CLAassistant
Copy link

CLAassistant commented Dec 22, 2021

CLA assistant check
All committers have signed the CLA.

@HJHGJGHHG
Copy link
Contributor Author

预训练模型位置

1.spiece.model

2.model_state.pdparams

@gongel
Copy link
Member

gongel commented Dec 23, 2021

@HJHGJGHHG 感谢贡献,麻烦签署一下CLA哈 #1499 (comment)

@HJHGJGHHG
Copy link
Contributor Author

HJHGJGHHG commented Dec 23, 2021 via email

@@ -0,0 +1,871 @@
# encoding=utf8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

paddlenlp 仅支持python3.6+,不需要指定编码。可以删去

Copy link
Contributor Author

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):
Copy link
Contributor

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()是否可以满足需求?

Copy link
Contributor Author

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,)
Copy link
Contributor

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,)
Copy link
Contributor

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,)
Copy link
Contributor

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,)
Copy link
Contributor

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
Copy link
Contributor

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))
Copy link
Contributor

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封装会可能导致出错堆栈信息复杂。直接调用即可。

Copy link
Contributor Author

@HJHGJGHHG HJHGJGHHG left a 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
Copy link
Contributor Author

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):
Copy link
Contributor Author

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()拆成两部分,更为精简。

Steffy-zxf
Steffy-zxf previously approved these changes Dec 31, 2021
Copy link
Contributor

@Steffy-zxf Steffy-zxf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HJHGJGHHG HJHGJGHHG closed this Jan 4, 2022
@HJHGJGHHG HJHGJGHHG reopened this Jan 4, 2022
@yingyibiao
Copy link
Contributor

参考其他模型给modeling.py和tokenizer.py这两个文件添加docstrings

Copy link
Contributor Author

@HJHGJGHHG HJHGJGHHG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已添加docstring

@yingyibiao
Copy link
Contributor

@HJHGJGHHG
Copy link
Contributor Author

@HJHGJGHHG
Copy link
Contributor Author

已上传至百度网盘
链接:https://pan.baidu.com/s/1O-cnSmuu6pqBOQp0VNe6CA
提取码:elnl

Copy link
Contributor

@yingyibiao yingyibiao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yingyibiao yingyibiao merged commit 737e4fa into PaddlePaddle:develop Jan 11, 2022
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

Successfully merging this pull request may close these issues.

6 participants