# numpy.dstack

`numpy.dstack`(tup)[source]

Stack arrays in sequence depth wise (along third axis).

This is equivalent to concatenation along the third axis after 2-D arrays of shape (M,N) have been reshaped to (M,N,1) and 1-D arrays of shape (N,) have been reshaped to (1,N,1). Rebuilds arrays divided by `dsplit`.

This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions `concatenate`, `stack` and `block` provide more general stacking and concatenation operations.

Parameters:

tup : sequence of arrays The arrays must have the same shape along all but the third axis. 1-D or 2-D arrays must have the same shape.

Returns:

stacked : ndarray The array formed by stacking the given arrays, will be at least 3-D.

`stack`

Join a sequence of arrays along a new axis.

`vstack`

Stack along first axis.

`hstack`

Stack along second axis.

`concatenate`

Join a sequence of arrays along an existing axis.

`dsplit`

Split array along third axis.

Examples

```>>>

>>> a = np.array((1,2,3))
>>> b = np.array((2,3,4))
>>> np.dstack((a,b))
array([[[1, 2],
[2, 3],
[3, 4]]])

>>>

>>> a = np.array([[1],[2],[3]])
>>> b = np.array([[2],[3],[4]])
>>> np.dstack((a,b))
array([[[1, 2]],
[[2, 3]],
[[3, 4]]])```

0 条评论

• ### numpy.hstack

版权声明：本文为博主原创文章，遵循 CC 4.0 BY-SA 版权协议，转载请附上原文出处链接和本声明。 ...

• ### numpy.vstack

版权声明：本文为博主原创文章，遵循 CC 4.0 BY-SA 版权协议，转载请附上原文出处链接和本声明。

• ### 计算机视觉中的细节问题

单阶段检测器训练的时候提出直接用已知的类进行分类和回归，而多阶段检测器先提出proposal，然后根据图像中目标的坐标和大小对proposal进行筛选，之后进行...

• ### 如何具体实践微服务

服务框架是一个比较成熟的领域，有太多可选项。Spring Boot/Cloud，由于 Spring 社区的影响力和 Netflix 的背书，目前可以认为是构建 ...

• ### 从单体应用走向服务化

之前讲解了什么是微服务：微服务的核心在于服务治理，微服务架构是将复杂臃肿的单体应用进行细粒度的服务化拆分，每个拆分出来的服务各自独立打包部署，并交由小团队进行开...

• ### 从单体应用走向服务化

之前讲解了什么是微服务：微服务的核心在于服务治理，微服务架构是将复杂臃肿的单体应用进行细粒度的服务化拆分，每个拆分出来的服务各自独立打包部署，并交由小团队进行开...

• ### 学习笔记-小甲鱼Python3学习第十七

优秀的东西永远是经典的，经典的东西永远是简单的，不是说复杂不好，而是能够把复杂的东西简单化，堪称经典。