C2_W3_A1 Tensor normalization function

Greetings!

How does normalize(image) transforms an image into a tensor of shape (64 * 64 * 3, )?
I see that the function flattens out the input tensor into 1D.

1 Like

Yes, that’s what that call to tf.reshape does. It gives the desired shape as [-1,], which means a 1D tensor and the meaning of the -1 in that syntax is “use all the remaining size of the object in this dimension”.

Since the input is 64 x 64 x 3, that gives you a total of 64 * 64 * 3 = 12288 elements in that one dimension.

I see.
But this means that the comment describing the function should be revised.

1 Like

Yes, that’s a good point that the “docstring” comment should not be that specific about the dimensions. It’s a general purpose routine that would work with any size of images.

I don’t think you posted this under the right course; this is probably Tensorflow Developer Certificate, Specialization.

Yes, I double checked: the course ID from the thread title is correct.