Tensor Shape-Shifting: See Shapes Before Values
·33 words·1 min
Awesome hack:
Want to see the shapes of tensor first while debugging in VSCode?
Just run this:
torch.Tensor.repr = lambda self: f"{tuple(self.shape)}:{normal_repr(self)}"
It replaces Tensor’s repr so that it shows shape first!