Solved by ptrblck in post #4 
              
              
                Your example is correct. 
Note that you should wrap this tensor in nn.Parameter, if you would like to optimize it inside an nn.Module. nn.Parameters will be automatically registered inside modules, if you use assign them as attributes: 
class MyModule(nn.Module):
    def __init__(self):
        supe…