Tensorflow.js tf.logSumExp() 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.logSumExp() function is used to calculate log sum exp of elements of a Tensor across its dimension. It reduces the given input elements along the dimensions of axes. If the parameter "keepDims" is true, the reduced dimensions are retained with length 1 else the rank of Tensor is reduced by 1. If the axes parameter has no entries, it returns a Tensor with a single element with all reduced dimensions. Syntax: tf.logSumExp (x, axis, keepDims) Parameters: This function accepts three parameters which are illustrated below: x: The input tensor.axis: The specified dimension(s) to reduce. By default it reduces all dimensions. It is optional parameter.keepDims: If this parameter value is true, it retains reduced dimensions with length 1 else the rank of Tensor is reduced by 1. It is also optional parameter. Return Value: It returns a Tensor of calculated value of log sum exp operation. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Initializing a some tensors const a = tf.tensor1d([0, 1]); const b = tf.tensor1d([3, 5]); const c = tf.tensor1d([2, 4, 7]); // Calling the .logSumExp() function over // the above tensors a.logSumExp().print(); b.logSumExp().print(); c.logSumExp().print(); Output: Tensor 1.31326162815094 Tensor 5.126927852630615 Tensor 7.054985046386719 Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Initializing a some tensors const a = tf.tensor1d([0, 1]); const b = tf.tensor2d([3, 5, 2, 8], [2, 2]); const c = tf.tensor1d([2, 4, 7]); // Initializing a axis parameters const axis1 = -1; const axis2 = -2; const axis3 = 0; // Calling the .logSumExp() function over // the above tensors a.logSumExp(axis1).print(); b.logSumExp(axis2, true).print(); c.logSumExp(axis1, false).print(); b.logSumExp(axis3, false).print(); Output: Tensor 1.31326162815094 Tensor [[3.3132617, 8.0485878],] Tensor 7.054985046386719 Tensor [3.3132617, 8.0485878] Reference:https://js.tensorflow.org/api/latest/#logSumExp Comment More infoAdvertise with us Next Article Tensorflow.js tf.logSumExp() Function K Kanchan_Ray Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.log1p() 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 .log1p() function is used to find the natural logarithm of the stated tensor input plus one i.e. ln(1 + x) an 1 min read Tensorflow.js tf.log() 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 .log() function is used to find the natural logarithm of the stated tensor input i.e. ln(x) and is done eleme 1 min read Tensorflow.js tf.sum() 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.sum() function is used to calculate sum of the elements of a specified Tensor across its dimension. It reduces the given input 2 min read Tensorflow.js tf.logSoftmax() 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. 1 min read Tensorflow.js tf.max() 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.max() function is used to calculate the maximum value from the specified Tensor across its dimension. It reduces the given inpu 2 min read Tensorflow.js tf.logSigmoid() 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 .logSigmoid() function is used to find the log sigmoid of the stated tensor input and is done element wise. S 1 min read Tensorflow.js tf.selu() 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 .selu() function is used to find the scaled exponential linear and is done element wise. Syntax: Â tf.selu(x) Where 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.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.squeeze() 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 .squeeze() function is used to discard the dimensions of length one out of the shape of a stated tf.Tensor. Syntax 2 min read Like