mxnet.ndarray.concat()用法举例

>>> from mxnet import nd
>>> x=nd.array([[1,1],[2,2]])
>>> y=nd.array([[3,3],[4,4]])
>>> z=nd.array([[5,5],[6,6]])
>>>x,y,z
[[1. 1.]
 [2. 2.]]
<NDArray 2x2 @cpu(0)>,
[[3. 3.]
 [4. 4.]]
<NDArray 2x2 @cpu(0)>,
[[5. 5.]
 [6. 6.]]
<NDArray 2x2 @cpu(0)>
>>>type(x)
<class ' mxnet.ndarray.ndarray.NDArray'>
>>> nd.concat(x,y,z,dim=0)
[[1. 1.]
 [2. 2.]
 [3. 3.]
 [4. 4.]
 [5. 5.]
 [6. 6.]]
<NDArray 6x2 @cpu(0)>
>>>
>>> nd.concat(x,y,z,dim=1)
[[1. 1. 3. 3. 5. 5.]
 [2. 2. 4. 4. 6. 6.]]
<NDArray 2x6 @cpu(0)>
>>> nd.concat(x,y,z,dim=2)
...
axis 2 exceeds the input dimension of 2>
>>>
>>> nd.concat(x,y,z,dim=-1)
[[1. 1. 3. 3. 5. 5.]
 [2. 2. 4. 4. 6. 6.]]
<NDArray 2x6 @cpu(0)>
>>>
>>> nd.concat(x,y,z,dim=-2)
[[1. 1.]
 [2. 2.]
 [3. 3.]
 [4. 4.]
 [5. 5.]
 [6. 6.]]
<NDArray 6x2 @cpu(0)>
>>>
>>> nd.concat(x,y,z,dim=-3)
...
axis -3 exceeds the input dimension of 2>

你可能感兴趣的:(python,mxnet)