#its not built in but you can get RMSE like so: criterion = nn.MSELoss() loss = torch.sqrt(criterion(x, y)) loss.backward() print(x.grad)