Tensorflow.js tf.layers.gru() Function Last Updated : 17 Jun, 2021 Comments Improve Suggest changes 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. Tensorflow.js tf.layers.gru() function is used to create a RNN layer which consists of only one GRUCell and the apply method of this layer operates on a sequence of input tensors. The shape of input tensor must be atleast 2D and the first dimension must be time steps. gru is Gated Recurrent Unit. Syntax: tf.layers.gru(args) Parameters: args: It specifies the given config object. recurrentActivation: It specifies the activation function which will be used for the recurrent step. The default value of this parameter is hard sigmoid. implementation: It specifies the implementation mode. It can be either 1 or 2. For superior performance implementation is recommended. Return value: It returns a tf.layers.Layer Example 1: JavaScript // Importing the tensorflow.js library const tf = require("@tensorflow/tfjs"); // Create a RNN model with gru Layer const RNN = tf.layers.gru({units: 8, returnSequences: true}); // Create an input which will have 5 time steps const input = tf.input({shape: [5, 10]}); const output = RNN.apply(input); console.log(JSON.stringify(output.shape)); Output: [null, 5, 8] Example 2: JavaScript // Importing the tensorflow.js library const tf = require("@tensorflow/tfjs"); // Create a new model with gru Layer const rnn = tf.layers.gru({units: 4, returnSequences: true}); // Create a 3d tensor const x = tf.tensor3d([ [ [1, 2], [3, 4], ], [ [5, 6], [7, 8], ], ]); // Apply gru layer to x const output = rnn.apply(x); // Print output output.print() Output: Reference: https://js.tensorflow.org/api/1.0.0/#layers.gru Comment More infoAdvertise with us Next Article Tensorflow.js tf.layers.gru() Function A abhinavjain194 Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Tensorflow.js-Recruitment Similar Reads Tensorflow.js tf.layers.gruCell() Function Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .layers.gruCell( ) function is used to create a cell class for GRU. Syntax: tf.layers.gruCell (args) Paramete 4 min read Tensorflow.js tf.layers.elu() 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. It also helps the developers to develop ML models in JavaScript language and can use ML directly in the browser or Node.js. The tf.lay 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.reLU() 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. 2 min read Tensorflow.js tf.layers.prelu() 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. 2 min read Like