def getShape(obj): print(obj.shape) getShape(np.zeros([2, 3])) getShape(torch.zeros(2, 3))
By passing an ndarray or tensor to a function and calling getShape() get the shape of both with the same call.
ndarray
tensor
getShape()