1D Arrays Vs 2D Arrays

Hi all,

In Mr. Ng Andrew’s lectures he said that [[200, 17]] is different than [200,17].

If even the 1D array has two numbers inside of it, what estimation does that represent to be called one dimensional since the figures are 2? Isn’t it still 1x2? And how do we interpret 2 numbers inside single brackets?

Looking forward for your reply

Thanks in advance!

Try printing the shape of each of the arrays, e.g. by doing:

print(f"w.shape = {w.shape}")

What you will see is that the first one with double brackets will have a shape of (1,2). The second one with single brackets will have a shape if (2,).

So what that means it that the second one literally has only one dimension. So it is a “vector”, but it has no orientation as a “row vector” or a “column vector”. That idea doesn’t make sense with only 1 dimension. The 2D object is a row vector with dimensions 1 x 2. That is very different and that is what Prof Ng means by saying that the two are different.

1 Like

Actually here’s a brand new thread from mentor @AbdElRhaman_Fakhry that exactly addresses your question. Please have a look!

1 Like