You can zero the gradients on all other rows, so that you you don’t use those gradients when updating the weights:
weights = Variable(torch.randn(3, 3, 3) , requires_grad=True)

weights.grad.data[1:].zero_()