Solved by eqy in post #2 
              
              
                You can manually set the parameters in a layer (e.g., 
mylayer = torch.nn.Conv2d(1,1,1,1)
mylayer.weight = ...

However, this is typically not done because the layers are trained with gradient descent. Predefined filters are more of a hallmark of classical computer vision for tasks like line and cor…