qml.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 and TensorFlow 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 = tf.constant([0.6, 0.1, 0.6])
>>> y = tf.Variable([0.1, 0.2, 0.3])
>>> z = np.array([5., 8., 101.])
>>> concatenate([x, y, z])
<tf.Tensor: shape=(9,), dtype=float32, numpy=
array([6.00e-01, 1.00e-01, 6.00e-01, 1.00e-01, 2.00e-01, 3.00e-01,
       5.00e+00, 8.00e+00, 1.01e+02], dtype=float32)>

Contents

Using PennyLane

Release news

Development

API

Internals