TypeError: module() takes at most 2 arguments (3 given)
這是我的報錯代碼
importos
importmath
importpaddle
importpaddle.nnasnn
from.backboneimportResNet
classxxxx(nn.layer):# <------------------------- 這裡報錯def__init__(self,
backbone_cfg=None,
neck_cfg=None,
head_cfg=None,
loss_cfg=None,
如果你也是這樣,在定義 class 的時候報了這個問題
那應該是和我一樣的,代碼中nn.layer
是一個 module 而不是一個類的名字
打印一下:
>>>nn.layer
<module'paddle.nn.layer'from'xxxxxib/python3.7/site-packages/paddle/nn/layer/__init__.py'>
我是因爲大小寫的問題,把 nn.layer 改成 nn.Layer 就對了
>>>nn.Layer
<class'paddle.fluid.dygraph.layers.Layer'>
0條評論