Hi Sunny (and Sajad)!



 Sunshine352:

A = torch.Tensor([ [ [0,0,0,0,0], [0,-0.4,0,-0.9,0], [0,-0.7,0.9,0.2,0], [0,0,0,0,0] ] ])
B = A[A.sum(dim=2) != 0]
tensor([[ 0.0000, -0.4000,  0.0000, -0.9000,  0.0000],
[ 0.0000, -0.7000,  0.9000,  0.2000,  0.0000]])


That’s a nice solution.
Note, you should add an absolute-value in there to avoid deleting
a non-zero row that sums to zero, such as [1.0, -1.0, 0.0].
Best.
K. Frank