Tensorflow.js tf.layers.concatenate() Function Last Updated : 21 Jul, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment. The tf.layers.concatenate() function is used to concatenate an array of inputs. Syntax: tf.layers.concatenate() Parameters: args(Object): specifies the given object. It is an optional parameteraxis(number): specifies the axis along which the inputs will concatenate. Its follows 0 based indexing and its value must be in the range [-rank, rank). It can be positive as well as negative. Here, positive axis ranges from 0 to rank(values) and specifies axis-th dimension. Negative value specifies axis + rank(values)-th dimension. It can be positive as well as negative. Default value is 0.inputShape: If this parameter is defined, it will create another input layer to insert before this layer.batchInputShape: If this parameter is defined, it will create another input layer to insert before this layer.batchSize : Used to construct batchInputShape, if not already specified.dtype: Specifies the data-type for this layer. Defaults value of this parameter is 'float32'.name: Specifies name for this layer.trainable: Specifies whether the weights of this layer are updatable by fit.weights: Specifies the initial weight values of the layer.inputDType : 'float32' or 'int32' or 'bool' or 'complex64' or 'string'. Return Value: A single tensor, which is the concatenation of all inputs. Example 1: JavaScript // Import the library import * as tf from "@tensorflow/tfjs" // Inputs const input1 = tf.input({shape: [3, 2]}) const input2 = tf.input({shape: [3, 2]}) const input3 = tf.input({shape: [3, 2]}) // Create new concatenate layer const concatenateLayer = tf.layers.concatenate(); const output = concatenateLayer.apply([input1, input2, input3]); // Print shape of resulting tensor console.log(JSON.stringify(output.shape)); Output: [pre][null, 3, 6] Example 2: JavaScript // Import the library import * as tf from "@tensorflow/tfjs" // Inputs const input1 = tf.tensor([-2, 1, 0, 5]); const input2 = tf.tensor([3, 2, 3, 2]); const input3 = tf.tensor([4, 3, 1, 2]); // Create new concatenate layer const concatLayer = tf.layers.concatenate(); const output = concatLayer.apply([input1, input2, input3]); // Print resulting tensor console.log(output); Output: Tensor [-2, 1, 0, 5, 3, 2, 3, 2, 4, 3, 1, 2] Reference: https://js.tensorflow.org/api/latest/#layers.concatenate Comment More infoAdvertise with us Next Article Tensorflow.js tf.layers.flatten() Function A abhinavjain194 Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Tensorflow.js-Merge Similar Reads Tensorflow.js tf.layers.flatten() Function Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment. The tf.layers.flatten() function is used to flatten the input, without affecting the batch size. A Flatten layer flattens each batch i 2 min read Tensorflow.js tf.layers.dot() Function Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment. Tensorflow.js tf.layers.dot() function is used to apply the dot product between the two tensors provided. Syntax:Â tf.layers.dot(args) 3 min read Tensorflow.js tf.layers.dense() Function The tf.layers.dense() is an inbuilt function of Tensorflow.js library. This function is used to create fully connected layers, in which every output depends on every input. Syntax: tf.layers.dense(args)Parameters: This function takes the args object as a parameter which can have the following proper 3 min read Tensorflow.js tf.layers.conv2d() Function Tensorflow.js is a Google-developed open-source toolkit for executing machine learning models and deep learning neural networks in the browser or on the node platform. It also enables developers to create machine learning models in JavaScript and utilize them directly in the browser or with Node.js. 3 min read Tensorflow.js tf.layers.conv3d() Function Tensorflow.js is a Google-developed open-source toolkit for executing machine learning models and deep learning neural networks in the browser or on the node platform. It also enables developers to create machine learning models in JavaScript and utilize them directly in the browser or with Node.js. 3 min read Tensorflow.js tf.layers.conv1d() Function Tensorflow.js is a javascript library developed by Google to run and train machine learning models in the browser or in Node.js. Tensorflow.js tf.layers.conv1d() function is used to create convolution layer. It is used to applied 1d convolution to the input data. The convolutional layer is used to m 4 min read Like