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

got the wrong result when using paconvet #340

Open
GreatV opened this issue Dec 3, 2023 · 3 comments
Open

got the wrong result when using paconvet #340

GreatV opened this issue Dec 3, 2023 · 3 comments
Labels
PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc

Comments

@GreatV
Copy link
Contributor

GreatV commented Dec 3, 2023

  • pytorch
import torch.nn as nn
from functools import partial


class test(nn.Module):
    def __init__(self, in_channels, out_channels, norm_func=nn.LayerNorm):
        super(test, self).__init__()
        self.norm = norm_func(in_channels)
        self.linear = nn.Linear(in_channels, out_channels)
    
    def forward(self, x):
        x = self.norm(x)
        x = self.linear(x)
        return x

if __name__ == "__main__":
    model = test(10, 10, partial(nn.LayerNorm, eps=0.2))
  • paddle
import paddle
from functools import partial


class test(paddle.nn.Layer):

    def __init__(self, in_channels, out_channels, norm_func=paddle.nn.LayerNorm
        ):
        super(test, self).__init__()
        self.norm = norm_func(in_channels)
        self.linear = paddle.nn.Linear(in_features=in_channels,
            out_features=out_channels)

    def forward(self, x):
        x = self.norm(x)
        x = self.linear(x)
        return x


if __name__ == '__main__':
    model = test(10, 10, partial(paddle.nn.LayerNorm, eps=0.2))
Traceback (most recent call last):
  File "/home/greatx/repos/PaConvert/paddle_project/test.py", line 21, in <module>
    model = test(10, 10, partial(paddle.nn.LayerNorm, eps=0.2))
  File "/home/greatx/repos/PaConvert/paddle_project/test.py", line 10, in __init__
    self.norm = norm_func(in_channels)
TypeError: LayerNorm.__init__() got an unexpected keyword argument 'eps'

eps should be converted to epsilon.

@paddle-bot paddle-bot bot added the PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc label Dec 3, 2023
@zhwesky2010
Copy link
Collaborator

@GreatV 你好,partial 形式的代码目前还不支持转换,这个可能后续会支持。另外再请问一下,这个case是具体实际模型中的用法case吗?

@zhwesky2010
Copy link
Collaborator

@GreatV 收到,我们后续评估新功能需求。

@GreatV GreatV closed this as completed Feb 5, 2024
@zhwesky2010 zhwesky2010 reopened this Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc
Projects
None yet
Development

No branches or pull requests

2 participants