Sunday, October 28, 2018

Python Code to convert or reshape 2D to 3D matrix array

from numpy import array
# list of data
data = [[11, 22],
[33, 44],
[55, 66]]
# array of data
data = array(data)
print(data.shape)
# reshape
data = data.reshape((data.shape[0], data.shape[1], 1))
print(data.shape)

Output:

(3, 2)
(3, 2, 1)

No comments:

Post a Comment