Apr-22-2022, 02:10 PM
I tried to reshape a 3-D matrix using two different ways.
If the end result is 1-D the two methods match
If the end result is 2-D the two method fails
this code works
If the end result is 1-D the two methods match
If the end result is 2-D the two method fails
this code works
a=np.random.randn(3,3,2) b1 = a.reshape(1,-1).T c1 = np.reshape(a,(-1,1))This code doesn't work
a=np.random.randn(3,3,2) b1 = a.reshape(2,-1).T c1 = np.reshape(a,(-1,2))
Output:a
array([[[-0.16364639, 1.18156333],
[-1.39645684, 0.82572665],
[ 0.49265179, -1.46054375]],
[[-0.94382502, -0.22524816],
[ 1.41986348, 2.0772036 ],
[ 0.80148826, -1.24641239]],
[[-0.09497732, 0.49188412],
[ 0.00413193, -0.79643808],
[ 0.09446335, -1.02043438]]])
b1 == c1
array([[ True, False],
[False, False],
[False, False],
[False, False],
[False, False],
[False, False],
[False, False],
[False, False],
[False, True]])
any explanation for that?