'How to print dataset sample like shown in first and second pictures, rather than third picture?

This is the first sample from MNIST dataset, as you could see, data is more expressive in first and second pictures, where we could also see the class when observed/stared carefully, you could see 5 in the dataset sample shown in first two pictures. I want to print the dataset sample everytime in this way. Because if you look at the third picture the way the dataset sample displayed is not that efficient. It looks better when the sample says that it has a shape of 28x28 and prints and displays 28x28 like the first two pictures.

First picture

Second Picture

Third Picture



Solution 1:[1]

This gave me a result that looks like your first pic:

my_tensor = torch.Tensor([np.zeros(10) for _ in range(20)])
print(my_tensor.numpy())

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 StBlaize