How to understand the ndarray.reshape function?

The prototype reshape()is reshape(shape, order="C"), and the type of form is a tuple. Therefore, we must call this function with myarray.reshape((1000, 1, 32, 32)), but I believe that many use myarray.reshape(1000, 1, 32, 32), why?

+2
source share
1 answer

This is a bit of hidden flexibility built into the method reshape.

The keyword here should be explicit: you cannot do, for example:

myarray.reshape(1000, 1, 32, 32, "C")

You will get TypeErrorby indicating that an integer is required.

(In fact, even using a tuple:

myarray.reshape((1000, 1, 32, 32), "C")

causes TypeError.)

(, GitHub, , 0 1. . , ( ).


, : , .
.
.

, , , (). .

+3
source

Source: https://habr.com/ru/post/1651975/


All Articles