Created
May 19, 2021 01:22
-
-
Save rayepeng/84bee9cdda754f291f3948f24fd6c167 to your computer and use it in GitHub Desktop.
numpy reshape用法 #Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: import numpy as np | |
In [2]: arr = np.array([1,2,3,4,5,6]) | |
In [3]: arr = arr.reshape(2,1,3) | |
In [4]: arr | |
Out[4]: | |
array([[[1, 2, 3]], | |
[[4, 5, 6]]]) | |
In [5]: brr = np.array([1,2,3,4,5,6,7,8,9,10,11,12]) | |
In [6]: brr = brr.reshape(2,2,3) | |
In [7]: brr | |
Out[7]: | |
array([[[ 1, 2, 3], | |
[ 4, 5, 6]], | |
[[ 7, 8, 9], | |
[10, 11, 12]]]) | |
In [8]: crr = np.array([1,2,3]) | |
In [9]: crr =crr.reshape(1,1,3) | |
In [10]: crr | |
Out[10]: array([[[1, 2, 3]]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment