Closed ToddBear closed 1 year ago
版本:
跑下面的demo代码出错:
import paddle import torch from padiff import auto_diff import torch import paddle class SimpleModule(torch.nn.Module): def __init__(self): super(SimpleModule, self).__init__() self.linear1 = torch.nn.Linear(100, 10) def forward(self, x): x = self.linear1(x) return x class SimpleLayer(paddle.nn.Layer): def __init__(self): super(SimpleLayer, self).__init__() self.linear1 = paddle.nn.Linear(100, 10) def forward(self, x): x = self.linear1(x) return x module = SimpleModule() layer = SimpleLayer() inp = paddle.rand((100, 100)).numpy().astype("float32") inp = ({'x': torch.as_tensor(inp) }, {'x': paddle.to_tensor(inp)}) auto_diff(module, layer, inp, atol=1e-4, auto_init=True)
报错信息如下:
Traceback (most recent call last): File "padiff_test.py", line 63, in <module> auto_diff(module, layer, inp, atol=1e-4, auto_init=True) TypeError: auto_diff() got an unexpected keyword argument 'atol'
Toturial里的命令与padiff==0.2.0版本的源码不一致,使用下面的命令运行成功:
auto_diff(layer, module, inp, steps=1, options={"atol":1e-4, "compare_mode":"strict"})
版本:
跑下面的demo代码出错:
报错信息如下: