Tensorflow.js tf.reverse() Function Last Updated : 11 Jul, 2022 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. It also helps the developers to develop ML models in JavaScript language and can use ML directly in the browser or in Node.js. The tf.reverse() function is used to reverse a tf.tensors along a specific axis. Syntax: tf.reverse(x, axis) Parameters: x: An input tensor to be reversed.axis: The set of dimensions to be set. Return Value: This function returns tf.Tensor. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Creating a tensor const gfg = tf.tensor1d([4, 3, 2, 1]); // Printing tensor gfg.reverse().print(); Output: Tensor [1, 2, 3, 4] Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Creating a tensor const x = tf.tensor2d([2, 1, 4, 3, 6, 5], [3, 2]); // Initialize the axis const axis = 1; // Printing the tensor x.reverse(axis).print(); Output: Tensor [[1, 2], [3, 4], [5, 6]] Reference: https://js.tensorflow.org/api/latest/#reverse Comment More infoAdvertise with us Next Article Tensorflow.js tf.reverse() Function T taran910 Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.reshape() 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.res 2 min read Tensorflow.js tf.step() 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.step() function is used to return the step of the input tensor's elements i.e. it returns 1 if the element is greater than 0 el 1 min read Tensorflow.js tf.ones() Function Tensorflow.js is an open-source library for running machine learning models and deep learning neural networks in the browser or node environment. The tf.ones() function is used to create a new tensor where all elements are set to 1. Syntax: tf.ones(shape, dtype, name) Parameters: shape: It takes the 2 min read Tensorflow.js tf.prelu() Function Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .prelu() function is used to find leaky rectified linear of the stated tensor input along with parametric alphas an 2 min read Tensorflow.js tf.range() 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. range() is used to create a new tf.Tensor1D filled with the numbers in the range provided with the help of start, stop, step, 2 min read Like