Lets say you have an array with N lines, each line being a 3*32*32=3072 long array. If you don't know for sure how many lines there are, but know you want the rest reshaped to (3, 32, 32), you can use the indicated line.
Otherwise you would get an error:
>>> import numpy as np
>>> n_lines = 10
>>> data = np.arange(n_lines*3*32*32)
>>> data.reshape(n_lines + 1 , 3*32*32) # notice the + 1 !!
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: total size of new array must be unchanged
But if you use the correct number:
>>> data.reshape(n_lines, 3*32*32)
array([[ 0, 1, 2, ..., 3069, 3070, 3071],
[ 3072, 3073, 3074, ..., 6141, 6142, 6143],
[ 6144, 6145, 6146, ..., 9213, 9214, 9215],
...,
[21504, 21505, 21506, ..., 24573, 24574, 24575],
[24576, 24577, 24578, ..., 27645, 27646, 27647],
[27648, 27649, 27650, ..., 30717, 30718, 30719]])
>>> data.reshape(n_lines, 3, 32, 32)
array([[[[ 0, 1, 2, ..., 29, 30, 31],
[ 32, 33, 34, ..., 61, 62, 63],
[ 64, 65, 66, ..., 93, 94, 95],
...,
[ 928, 929, 930, ..., 957, 958, 959],
[ 960, 961, 962, ..., 989, 990, 991],
[ 992, 993, 994, ..., 1021, 1022, 1023]],
[[ 1024, 1025, 1026, ...,
data? It has to be at least 2d, and thatdata.shape[1:]values have the same product as 3*32*32.