Tensorflow.js tf.randomGamma() Function Last Updated : 18 May, 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. The tf.randomGamma() function is used to create a tf.Tensor with values sampled from a gamma distribution. Syntax: tf.randomGamma(shape, alpha, beta, dtype, seed) Parameter: This function accepts three parameters which are illustrated below: shape: An array of integers defining the shape of the output tensor.alpha: The shape parameter of the gamma distribution.beta: It is an optional argument. The inverse scale parameter of the gamma distribution. The default value is 1.dtype: The data type of the output. The values of datatype possible are 'float32' or 'int32'. It is also an optional argument.seed: It is an optional argument. The seed for the random number generator. Return: It returns tf.Tensor Example 1: JavaScript // Importting the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Creating the tensor with values sampled // from a gamma distribution const x=tf.randomGamma([5], 0); // Printing the tensor x.print(); Output: Tensor [0, 0, 0, 0, 0] Example 2: JavaScript // Importting the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Creating the tensor with values sampled // from a gamma distribution const x=tf.randomGamma([5], 1); // Printing the tensor x.print(); Output: Tensor [1.4808178, 1.6668015, 0.9527208, 1.6024575, 1.6021353] Example 3: JavaScript // Importting the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Creating the tensor with values sampled // from a gamma distribution const x=tf.randomGamma([2,2], 1); // Printing the tensor x.print(); Output: Tensor [[0.1157758, 1.4427431], [0.4978852, 0.1617882]] Example 4: JavaScript // Importting the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Creating the tensor with values sampled // from a gamma distribution const x=tf.randomGamma([5], 1,2,'int32',98); // Printing the tensor x.print(); Output: Tensor [0, 1, 4, 0, 1] Reference:https://js.tensorflow.org/api/latest/#randomGamma Comment More infoAdvertise with us Next Article Tensorflow.js tf.randomGamma() Function C CoderSaty Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.randomNormal() 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.randomNormal() functi 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 Tensorflow.js tf.randomUniform() 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.randomUniform() function is used to create a tf.Tensor with values sampled from a uniform distribution. Syntax: tf.randomUnifor 2 min read 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.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 Like