Is there a simple way to zero the diagonal of a PyTorch tensor?
For example I have:
tensor([[2.7183, 0.4005, 2.7183, 0.5236],
[0.4005, 2.7183, 0.4004, 1.3469],
[2.7183, 0.4004, 2.7183, 0.5239],
[0.5236, 1.3469, 0.5239, 2.7183]])
And I want to get:
tensor([[0.0000, 0.4005, 2.7183, 0.5236],
[0.4005, 0.0000, 0.4004, 1.3469],
[2.7183, 0.4004, 0.0000, 0.5239],
[0.5236, 1.3469, 0.5239, 0.0000]])