Pythorch: .__init__() takes 1 positional argument but 2 were given

Hi all,

i am now facing a error: .init() takes 1 positional argument but 2 were given

my model is defined:

bc = datasets.load_breast_cancer()
X, y = bc.data, bc.target
n_samples, n_features = X.shape

class LogisticRegression(nn.Module):

def _init_(self, n_input_features):
    super(LogisticRegression, self)._init_()
    self.linear = nn.Linear(n_input_features, 1)
    
def forward(self, x):
    y_pred = torch.sigmoid(self.linear(x))
    return y_pred

model = LogisticRegression(n_features) —> here is the problem…

It works for me:

class LogisticRegression(nn.Module):
    def __init__(self, n_input_features):
        super(LogisticRegression, self).__init__()
        self.linear = nn.Linear(n_input_features, 1)
        
    def forward(self, x):
        y_pred = torch.sigmoid(self.linear(x))
        return y_pred

model = LogisticRegression(n_input_features=10)

after fixing the __init__ function definition and call (note the double underscores).

oha… that was such a stupid mistake. thanks a lot!!