问题记录:TypeError: __init__() takes 1 positional argument but 3 were given

class LinearRegressionModel(nn.Module):    #继承nn模块
    def _init_(self,input_dim,output_dim):
        super(LinearRegressionModel,self)._init_()
        self.linear=nn.Linear(input_dim,output_dim)
        
    def forward(self,x):
        out=self.linear(x)
        return out

input_dim=1
output_dim=1
model=LinearRegressionModel(input_dim,output_dim)

报错原因:__init__左右是两条短划线

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
 in 
      1 input_dim=1
      2 output_dim=1
----> 3 model=LinearRegressionModel(input_dim,output_dim)

TypeError: __init__() takes 1 positional argument but 3 were given

你可能感兴趣的:(深度学习pytorch问题记录,python)