jax.numpy.dstack — JAX documentation (original) (raw)

jax.numpy.dstack#

jax.numpy.dstack(tup, dtype=None)[source]#

Stack arrays depth-wise.

JAX implementation of numpy.dstack().

For arrays of three or more dimensions, this is equivalent tojax.numpy.concatenate() with axis=2.

Parameters:

Returns:

the stacked result.

Return type:

Array

See also

Examples

Scalar values:

jnp.dstack([1, 2, 3]) Array([[[1, 2, 3]]], dtype=int32, weak_type=True)

1D arrays:

x = jnp.arange(3) y = jnp.ones(3) jnp.dstack([x, y]) Array([[[0., 1.], [1., 1.], [2., 1.]]], dtype=float32)

2D arrays:

x = x.reshape(1, 3) y = y.reshape(1, 3) jnp.dstack([x, y]) Array([[[0., 1.], [1., 1.], [2., 1.]]], dtype=float32)