PaddlePaddle / PaddlePaddle/PaConvert
got the wrong result when using paconvet
Open
Nobody has claimed this yet.
PFCC
- Dominant language
- Python
- Stars
- 122
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the PaConvert conversion rule that handles LayerNorm arguments and the handling of functools.partial. Reproduce the provided Python example, then verify that the converted Paddle call accepts the equivalent epsilon argument and that the original TypeError no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100