Skip to content

got the wrong result when using paconvet #340

Description

@GreatV
  • 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    PFCCPaddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions