用途
numpy.reshape:
>>> import numpy as np>>> data = np.array( [0, 2, 7, 6, 3, 1, 4, 5] )>>> shape = ( 2, 4 )>>> data.reshape( shape )array([[0, 2, 7, 6], [3, 1, 4, 5]])
您也可以直接分配给
shape的属性
data,如果你想避免在内存中复制它:
>>> data.shape = shape

用途
numpy.reshape:
>>> import numpy as np>>> data = np.array( [0, 2, 7, 6, 3, 1, 4, 5] )>>> shape = ( 2, 4 )>>> data.reshape( shape )array([[0, 2, 7, 6], [3, 1, 4, 5]])
您也可以直接分配给
shape的属性
data,如果你想避免在内存中复制它:
>>> data.shape = shape