qp.math.concatenate

concatenate(values, axis=0, like=None)[source]

Concatenate a sequence of tensors along the specified axis.

Warning

Tensors that are incompatible (such as Torch tensors) cannot both be present.

Parameters:
  • values (Sequence[tensor_like]) – Sequence of tensor-like objects to concatenate. The objects must have the same shape, except in the dimension corresponding to axis (the first, by default).

  • axis (int) – The axis along which the input tensors are concatenated. If axis is None, tensors are flattened before use. Default is 0.

Returns:

The concatenated tensor.

Return type:

tensor_like

Example

>>> x = torch.tensor([0.6, 0.1, 0.6])
>>> y = torch.tensor([0.1, 0.2, 0.3])
>>> z = np.array([5., 8., 101.])
>>> concatenate([x, y, z])
tensor([6.0000e-01, 1.0000e-01, 6.0000e-01, 1.0000e-01, 2.0000e-01, 3.0000e-01,
        5.0000e+00, 8.0000e+00, 1.0100e+02], dtype=torch.float64)