Inspect

View statistics of tensors and other python containers
import torch, numpy as np
from torch_snippets import inspect

inspect(torch.randint(0, 100, size=(4, 3, 5)), np.random.randint(-10, 10, (9, 19, 1)))
══════════════════════════════════════════════════════════════════
Tensor  Shape: torch.Size([4, 3, 5])    Min: 2.000      Max: 97.000     Mean: 46.317    dtype: torch.int64 @ cpu
══════════════════════════════════════════════════════════════════
ndarray Shape: (9, 19, 1)       Min: -10.000    Max: 9.000      Mean: -0.345    dtype: int64
══════════════════════════════════════════════════════════════════
x = {
    "a": [0, 1, 2, 3],
    "b": torch.rand(10, 10),
    "c": {
        "d": np.arange(10),
        "e": [
            "np.arange",
            {},
            tuple(
                [
                    1,
                    2,
                ]
            ),
            set([1, 2, 3]),
            [],
            [11, 10],
        ],
    },
}
inspect(x)
══════════════════════════════════════════════════════════════════
dict of 3 items
        A:
        list of 4 items
                int: 0
                int: 1
                int: 2
                int: 3
        B:
        Tensor  Shape: torch.Size([10, 10])     Min: 0.000      Max: 0.989      Mean: 0.463     dtype: 
torch.float32 @ cpu
        C:
        dict of 2 items
                D:
                ndarray Shape: (10,)    Min: 0.000      Max: 9.000      Mean: 4.500     dtype: int64
                E:
                list of 6 items
                        str `np.arange`
                        dict of 0 items
                        tuple of 2 items
                                int: 1
                                int: 2
                        set Length: 3
                        list of 0 items
                        and ... ... 1 more item(s)
══════════════════════════════════════════════════════════════════