Solved by ptrblck in post #2 
              
              
                Do you just want the gradient for the first layer (input layer) or the input tensor? 
For the former you can just print the layer’s parameter’s grad, while you would need to set requires_grad=True for the latter: 
class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init_…