TypeError: module() takes at most 2 arguments (3 given)

TypeError: module() takes at most 2 arguments (3 given),第1張

這是我的報錯代碼

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'>

有蓡考自:


生活常識_百科知識_各類知識大全»TypeError: module() takes at most 2 arguments (3 given)

0條評論

    發表評論

    提供最優質的資源集郃

    立即查看了解詳情