Doubt about Tensorflow Tensor Shape in Week 3 Assignment 1

Hello,

While I was attempting the Programming Assignment for Week 3, I came accross this:
image
I need someone to confirm for me if my understanding about the shape of the Tensor is correct or not.
What I understand from (64, 64, 3) is that there are 64 images, each represented by a matrix of 64 rows and 3 columns.


Can you please tell if my understanding is correct?

I just tried one thing:
image
If I went with my understanding as above, it seems that something is off.

Instead of getting 64 as value of final print statement, I am getting 1080

Hi @sushantnair

Your understanding of the shape of the Tensor is not quite correct, let me clarify, in (64, 64, 3):

  • 64: The height of each image (64 pixels).
  • 64: The width of each image (64 pixels).
  • 3: The number of channels in each image (RGB Values).

If you have a batch of images, you add an additional dimension to the tensor shape. For example, if you have a batch of 32 images, each of size 64x64 with 3 channels, the tensor shape would be (32, 64, 64, 3).

Hope it helps!

1 Like

Yes exactly, I was feeling so. Because to check my understanding I made the aforementioned modification and got this result:
image
I think it shows that the train set has 1080 images. Am I correct?

Yes, from the text “x_train_tensor number 1080”, it indicates that there are 1080 images in the training set. The tensor shape for the entire dataset would then be (1080, 64, 64, 3).

1 Like

Thanks a lot @Alireza_Saei

Just one more thing. Please have a look at the image and let me know if I have got it right:


Thanks a lot for helping :smile:

1 Like

You’re welcome! Happy to help :raised_hands:

Yes, your interpretation is completely correct! If you need further assistance, feel free to ask!

1 Like