SoFunction
Updated on 2024-11-17

python 2D matrix to 3D matrix example

As shown below:

>>> import numpy as np
>>> a = (12).reshape(3,4)
>>> a
array([[ 0, 1, 2, 3],
    [ 4, 5, 6, 7],
    [ 8, 9, 10, 11]])
>>> type(a)
<class ''>
>>> b=(a,(3,4,1))
>>> (b)
(3, 4, 1)
>>> c=([b,b],2)
>>> (c)
(3, 4, 2)

For format variables only, constants are not allowed.

>>> b=([0,0,0])
>>> c=(b,(2,1))
>>> (c)
(2, 3)
>>> type(c)
<class ''>
>>> d=(c,(2,3,1))
>>> (d)

Above this python 2D matrix to 3D matrix example is all I have shared with you, I hope it can give you a reference, and I hope you support me more.