Pylint:self.xxx 不可调用

Pylint: self.xxx is not callable

我不确定为什么在我对 class 进行如下编码时出现此错误:

class Net(torch.nn.Module):
    self.architecture = {"backbone": None, "bottleneck": None, "head": None}
    self.architecture_name['backbone'] = model
    
    ...
    
    def forward(self, x):
        output = self.architecture['backbone'](x)
        ...

pylint的错误是当我调用self.architecture['backbone'](x)时,代码仍然运行,但我只是想知道这是否有任何问题。

尝试将函数放在字典文字中而不是稍后分配它。

class Net(torch.nn.Module):
    self.architecture = {"backbone": model, "bottleneck": None, "head": None}