Confused with reshaping

Why does my model work if I reshaped my training set with reshape(train_set_x_orig.shape[0], -1).T
but it doesn’t when i do it with reshape(-1, train_set_x_orig.shape[0]) ?

Shouldn’t these two lines be exactly the same? we are essentially just transposing the matrix.

Interesting question! No, the results are not the same. Here’s a thread which explains why in detail. The second method ends up “scrambling” the data by mixing elements of multiple input samples into each output column, so that the result is garbage.