C1_M1_Lab_3_tensors "Tensors: The Core of PyTorch"

I understand, it’s a very minor issue, but still… It looks to me that the suggested solution for the second task of the Exercise 2: “image_batch_transposed = image_batch_with_channel.transpose(1, 3)“ is not correct. Because it switches “width” and “channels“, so result is “[batch_size, width, height, channels]“ instead of [batch_size, height, width, channels] as required in the task. It’s not obvious in the result, because height = width = 3, so I would recommend using different values for the height and the width in the problem condition to avoid the confusion, and suggesting the correct solution: “image_batch_transposed = image_batch_with_channel.transpose(1,2).transpose(2,3)“
Thank you!

Thanks for pointing this out! I will file an enhancement request. I guess they were really trying to demonstrate how the transpose operator works, but there’s an even simpler solution here: they are just adding the unitary channels dimension, so they could have just added it as the new 4th dimension directly to get (m, h, w, c) by using unsqueeze(3). But I guess that’s not the pedagogical point here. :nerd_face:

1 Like