让我们用一个更小的玩具例子来试试这个吧? (警告:我想这真的取决于你实际的 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 是什么样的!