As in Python, the axis could also be negative numbers. Negative axis
are interpreted as counting from the end of the rank, i.e.,
axis + rank(values)-th dimension.
0-D int32Tensor. Dimension along which to concatenate. Must be
in the range [-rank(values), rank(values)). As in Python, indexing for
axis is 0-based. Positive axis in the rage of [0, rank(values)) refers
to axis-th dimension. And negative axis refers to axis +
rank(values)-th dimension.
name
A name for the operation (optional).
Returns
A Tensor resulting from concatenation of the input tensors.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.concat\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/array_ops.py#L1316-L1408) |\n\nConcatenates tensors along one dimension.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.concat`](https://www.tensorflow.org/api_docs/python/tf/concat)\n\n\u003cbr /\u003e\n\n tf.concat(\n values, axis, name='concat'\n )\n\n### Used in the notebooks\n\n| Used in the guide | Used in the tutorials |\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| - [Better performance with the tf.data API](https://www.tensorflow.org/guide/data_performance) - [Ragged tensors](https://www.tensorflow.org/guide/ragged_tensor) - [TensorFlow basics](https://www.tensorflow.org/guide/basics) - [Quickstart for the TensorFlow Core APIs](https://www.tensorflow.org/guide/core/quickstart_core) - [Customizing what happens in \\`fit()\\` with TensorFlow](https://www.tensorflow.org/guide/keras/custom_train_step_in_tensorflow) | - [Simple audio recognition: Recognizing keywords](https://www.tensorflow.org/tutorials/audio/simple_audio) - [Learned data compression](https://www.tensorflow.org/tutorials/generative/data_compression) - [Integrated gradients](https://www.tensorflow.org/tutorials/interpretability/integrated_gradients) - [Load a pandas DataFrame](https://www.tensorflow.org/tutorials/load_data/pandas_dataframe) - [Transfer learning for video classification with MoViNet](https://www.tensorflow.org/tutorials/video/transfer_learning_with_movinet) |\n\nSee also [`tf.tile`](../tf/tile), [`tf.stack`](../tf/stack), [`tf.repeat`](../tf/repeat).\n\nConcatenates the list of tensors `values` along dimension `axis`. If\n`values[i].shape = [D0, D1, ... Daxis(i), ...Dn]`, the concatenated\nresult has shape \n\n [D0, D1, ... Raxis, ...Dn]\n\nwhere \n\n Raxis = sum(Daxis(i))\n\nThat is, the data from the input tensors is joined along the `axis`\ndimension.\n\nThe number of dimensions of the input tensors must match, and all dimensions\nexcept `axis` must be equal.\n\n#### For example:\n\n t1 = [[1, 2, 3], [4, 5, 6]]\n t2 = [[7, 8, 9], [10, 11, 12]]\n tf.concat([t1, t2], 0)\n \u003ctf.Tensor: shape=(4, 3), dtype=int32, numpy=\n array([[ 1, 2, 3],\n [ 4, 5, 6],\n [ 7, 8, 9],\n [10, 11, 12]], dtype=int32)\u003e\n\n tf.concat([t1, t2], 1)\n \u003ctf.Tensor: shape=(2, 6), dtype=int32, numpy=\n array([[ 1, 2, 3, 7, 8, 9],\n [ 4, 5, 6, 10, 11, 12]], dtype=int32)\u003e\n\nAs in Python, the `axis` could also be negative numbers. Negative `axis`\nare interpreted as counting from the end of the rank, i.e.,\n`axis + rank(values)`-th dimension.\n\n#### For example:\n\n t1 = [[[1, 2], [2, 3]], [[4, 4], [5, 3]]]\n t2 = [[[7, 4], [8, 4]], [[2, 10], [15, 11]]]\n tf.concat([t1, t2], -1)\n \u003ctf.Tensor: shape=(2, 2, 4), dtype=int32, numpy=\n array([[[ 1, 2, 7, 4],\n [ 2, 3, 8, 4]],\n [[ 4, 4, 2, 10],\n [ 5, 3, 15, 11]]], dtype=int32)\u003e\n\n**Note:** If you are concatenating along a new axis consider using stack. E.g. \n\n tf.concat([tf.expand_dims(t, axis) for t in tensors], axis)\n\ncan be rewritten as \n\n tf.stack(tensors, axis=axis)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `values` | A list of `Tensor` objects or a single `Tensor`. |\n| `axis` | 0-D `int32` `Tensor`. Dimension along which to concatenate. Must be in the range `[-rank(values), rank(values))`. As in Python, indexing for axis is 0-based. Positive axis in the rage of `[0, rank(values))` refers to `axis`-th dimension. And negative axis refers to `axis + rank(values)`-th dimension. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Tensor` resulting from concatenation of the input tensors. ||\n\n\u003cbr /\u003e"]]