Home > OS >  Pylint: self.xxx is not callable
Pylint: self.xxx is not callable

Time:10-28

I am unsure why I am given this error when I coded my class as follows:

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)
        ...

The error from pylint is when I call self.architecture['backbone'](x), the code still runs, but I just wonder if there is anything wrong with this.

CodePudding user response:

Try putting the function in the dictionary literal instead of assigning it later.

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