Hello all!
I am currently working on chapter 4 of the notebook, and have a question on why we stack the three and seven tensors to compute the average pixel density.
Before this stacking operation, we use a list comprehension to create a list of rank-2 tensors if my understanding is correct, which looks like this:
seven_tensors = [tensor(Image.open(o)) for o in sevens]
three_tensors = [tensor(Image.open(o)) for o in threes]
This would then create a collection of rank-2 tensors, which should be itself a rank-3 tensor. Is this the right way of thinking about this? This appears to do the stacking before we actually call the stacking method later here:
stacked_sevens = torch.stack(seven_tensors).float()/255
stacked_threes = torch.stack(three_tensors).float()/255
If we compare the first element of each of these objects we get
print(seven_tensors[0].shape)
print(torch.stack(seven_tensors)[0].shape)
Output:
torch.Size([28, 28])
torch.Size([28, 28])
Are we calling the .stack() method on this already rank-3 tensor just to convert it from a list object to a Tensor? Instead of the list comprehension, couldn’t we stack those rank-2 tensors together to make the rank-3 tensor?
Thank you everyone for your time and help, I am glad to be joining this community!