Solved by ptrblck in post #2 
              
              
                You could use the functional API to define your parameters in the forward method. 
Here is a small example using a random number of kernels for the conv layer: 
class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.conv_weight = None
        self.conv…