Issue
I have an array B
with shape (1,9,1)
. Is it possible to convert into a new array B1
with shape (1,3,3)
? The desired output is attached.
import numpy as np
B=np.array([[[0.67873113],
[1.24442563],
[0.02109 ],
[0.76788408],
[2.00615422],
[3.07375839],
[1.037729 ],
[5.03294753],
[0.0105 ]]])
print("B shape =",B.shape)
The desired output is
B1=np.array([[[0.67873113,1.24442563,0.02109 ],
[0.76788408,2.00615422,3.07375839],
[1.037729,5.03294753,0.0105 ]]])
B1 shape = (1, 3, 3)
Solution
You can just reshape it. See here
B.reshape((1,3,3))
>>> array([[[0.67873113, 1.24442563, 0.02109 ],
[0.76788408, 2.00615422, 3.07375839],
[1.037729 , 5.03294753, 0.0105 ]]])
Answered By - Vishal Balaji
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.