-1
如果有一個數組中,x,即形狀[365,24,1]的,並且使用使用numpy.Reshape蟒
x = np.reshape(x,(8760))
和你具有相同的陣列,Y,但它的形狀是[24,365,1]和你使用
y = np.reshape(y,(8760))
你會得到相同的數組退出了x和y?還是混合不同的值?
如果有一個數組中,x,即形狀[365,24,1]的,並且使用使用numpy.Reshape蟒
x = np.reshape(x,(8760))
和你具有相同的陣列,Y,但它的形狀是[24,365,1]和你使用
y = np.reshape(y,(8760))
你會得到相同的數組退出了x和y?還是混合不同的值?
讓我們用一個較小的玩具例子來試試這個嗎?
In [1]: import numpy as np
In [2]: x = np.arange(24).reshape(2, 3, 4)
In [3]: x
Out[3]:
array([[[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]],
[[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]]])
In [4]: y = np.arange(24).reshape(2, 6, 2)
In [5]: y
Out[5]:
array([[[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7],
[ 8, 9],
[10, 11]],
[[12, 13],
[14, 15],
[16, 17],
[18, 19],
[20, 21],
[22, 23]]])
In [6]: x2 = x.reshape(24)
In [7]: x2
Out[7]:
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23])
In [8]: y2 = y.reshape(24)
In [9]: y2
Out[9]:
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23])
In [10]: x2 == y2
Out[10]:
array([ True, True, True, True, True, True, True, True, True,
True, True, True, True, True, True, True, True, True,
True, True, True, True, True, True], dtype=bool)
In [11]:
這種玩具結果顯示重塑x2
具有與重塑y2
相同的值:(警告我想這真的取決於你的實際x
和y
模樣雖然!)。你將需要檢查你的實際輸入x
和y
看起來像什麼!
你試過小例子嗎? –
如果'x'和'y'具有不同的形狀,它們可以相同嗎? –