Tensorflow.js tf.linspace() Function Last Updated : 18 May, 2021 Comments Improve Suggest changes Like Article Like Report 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 .linspace() function is used to find a regularly distanced series of numbers for a stated interval. Syntax : tf.linspace(start, stop, num) Parameters: start: It is the stated start value of the series which is to be generated and is of type number.stop: It is the stated end value of the series which is to be generated and is of type number.num: It is the stated number of values which are to be generated and is of type number. Return Value: It returns the tf.Tensor1D object. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Defining all the parameters var strt = 3; var stp = 20; var num = 5; // Calling linspace() method and // Printing output tf.linspace(strt, stp, num).print(); Output: Tensor [3, 7.25, 11.5, 15.75, 20] Example 2: Using float values for all the stated parameters. JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Calling linspace() method and // Printing output tf.linspace(12.4, 29.7, 5.4).print(); Output: Tensor [12.3999996, 16.3318176, 20.2636356, 24.1954536, 28.1272717] Reference: https://js.tensorflow.org/api/latest/#linspace Comment More infoAdvertise with us Next Article Tensorflow.js tf.linspace() Function nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.pad() 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 in Node.js. The tf. 2 min read Tensorflow.js tf.stack() 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 helps developers to develop ML models in JavaScript, and use ML directly in the browser or in Node.js. The tf.stack() function is u 2 min read Tensorflow.js tf.neg() Function Tensorflow.js is an open-source library which is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .neg() function is used to calculate -1 * x i.e. input tensor and is done element wise. Syntax: Â tf.neg(x) 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.square() 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.square() function is used to return the square of the specified tensor's elements. Syntax: tf.square(x) Parameters: This functi 1 min read Like