np.dstack works as expected for 2D arrays, but for some reason for 3D arrays it stack not by last dimension.
What is proper way for stack by last dimension for ND arrays?
Example:
import numpy as np
#2D
a = np.zeros((2,2,1))
a.shape
(2, 2, 1)
np.dstack([a] * 3).shape
(2, 2, 3)
#3D
b = np.zeros((8,2,2,1))
b.shape
(8, 2, 2, 1)
np.dstack([b] * 3).shape
(8, 2, 6, 1)