pangolin.interface.Interface.concatenate

pangolin.interface.Interface.concatenate#

Interface.concatenate(*arrays, axis=0)[source]#

Concatenate arrays along an existing axis without broadcasting.

Parameters:
  • *arrays (RVLike) – One or more arrays with the same rank and equal dimensions except along axis. Non-RV values are converted to constant RVs.

  • axis (int) – Existing axis along which to concatenate. Negative axes count from the end.

Returns:

ir.RV – Concatenated RV owned by this interface.

Return type:

RV

Examples

>>> import pangolin.interface as pi
>>> A = pi.constant([[1, 2], [3, 4]])
>>> B = pi.constant([[5, 6], [7, 8]])
>>> A.shape
(2, 2)
>>> B.shape
(2, 2)
>>> pi.concatenate(A, B).shape
(4, 2)
>>> pi.concatenate(A, B, axis=1).shape
(2, 4)

Random and deterministic RVs can be concatenated in the same way.

>>> x = pi.multi_normal([0, 0], [[1, 0], [0, 1]])
>>> pi.concatenate(x, pi.softmax(x)).shape
(4,)