cannot assign module before Module.__init__() call

 
 
Property error, module cannot assign value before initialization. The error may be caused by:

The initialization of the parent class is not added to the initialization of the class, for example:

class Conv2dBatchLeaky(nn.Module):
    def __init__(self, in_channels, out_channels, kernel_size, stride, leaky_slope=0.1):

        self.in_channels = in_channels
        self.out_channels = out_channels
        self.kernel_size = kernel_size

 
resolvent:

add:

super(Conv2dBatchLeaky, self).__ init__()

The code is as follows:

class Conv2dBatchLeaky(nn.Module):
    def __init__(self, in_channels, out_channels, kernel_size, stride, leaky_slope=0.1):
        super(Conv2dBatchLeaky, self).__init__()

        self.in_channels = in_channels
        self.out_channels = out_channels
        self.kernel_size = kernel_size

 

Read More: