1-liner for viewing the shape of all local Tensors in Python
gist.github.com
gist.github.com
Here's an example output:
Array Shapes:
==================================================
attention1 : Tensor : (8, 8921, 251)
m : Tensor : (8, 8921, 50)
ŷ0 : Tensor : (8, 8921, 50)
ŷ1 : Tensor : (8, 8921)
ŷ2 : Tensor : (8, 8921)
random_np_arr : ndarray: (2, 3)
And the code: print(f"\nArray Shapes:\n{'':=>50}"); [print(f"{k:<20}: {str(type(v).__name__):<7}:", tuple(v.shape)) for k, v in locals().items() if hasattr(v, "shape") and not hasattr(getattr(v, "shape", None), "__call__")] # Exclude the 'numpy' import, the `shape` func. isn't relevant
(semi-golfed to be able to easily run in a `breakpoint()`)