Tensorflow.js tf.log1p() Function
Last Updated :
12 May, 2021
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) and is done element wise.
Syntax:
tf.log1p(x)
Parameters: This function accepts three parameters which are illustrated below:
- x: It is the tensor input, and it can be of type tf.Tensor, or TypedArray, or Array.
Return Value: It returns the tf.Tensor object.
Example 1:
Javascript
import * as tf from "@tensorflow/tfjs"
const y = tf.tensor1d([1, 15, 38, Math.E-1]);
y.log1p().print();
|
Output:
Tensor
[0.6931472, 2.7725887, 3.6635618, 1]
Example 2: In this example, the parameter is passed directly to the log1p function.
Javascript
import * as tf from "@tensorflow/tfjs"
var val = [0.5, 1.5, .66];
const y = tf.tensor1d(val);
var res = tf.log1p(y)
res.print();
|
Output:
Tensor
[0.4054651, 0.9162908, 0.5068176]
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...