Image Vector Clarification

Hi Sir,

According to the below lecture slide, for single training example, first 64 rows red pixels stored, then next 64 rows only green value pixels stored followed by 64 Blue value pixel getting stored.


But in the programming assignment, this process not followed. They are doing like first row is red pixel value, second row is green pixel value, third row is blue pixel value then fourth row is red pixel fifth row ix green pixel and so on.

can u please let me know sir which process is correct and wrong ?

@paulinpaloalto Sir If u have sometime can you please help to answer this doubt?

It is a good observation that the picture shows something different than what they actually do. It turns out that either order will work fine, as long as you consistently use the same “reshape” command on all your input images. The reshape command gives what it calls “C” order as the default, which is to unroll across the highest dimension first, so you get the R, G and B values for each position in the image in order by the positions. If you ask for “F” order, then you get what they show in the picture: all the red pixels followed by all the green pixels followed by all the blue pixels. My guess is that Prof Ng’s course team was just learning python when they originally created this course and they hadn’t really studied the output of the reshape command carefully enough to see that the picture disagrees with what actually happens.

Here’s an earlier thread which discusses the reshaping in more detail. You need to read the later posts in the thread to see the discussion of the point that you are raising.