Shaping 4d tensor into 3d

my imshow function accepts a tensor of (1, 28, 28), but my dataloader is returning a tensor of (1000, 1, 28, 28). The “1000” seems to be the value of the batch_size that I specify in the loader. Is there anyway to fix this.

You could index the specific image tensor you would like to visualize:

my_imshow(data[0])

that worked. thank you!