Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptTensorflow.js tf.logSigmoid() Function

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.

Syntax:  

tf.logSigmoid(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




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Defining tensor input elements
const y = tf.tensor1d([1, 15, 38, Math.E]);
  
// Calling logSigmoid() method and
// printing output
y.logSigmoid().print();


Output:

Tensor
    [-0.3132617, -3e-7, 0, -0.0639021]

Example 2: In this example, the parameter is passed directly to the logSigmoid function.

Javascript




// Importing the tensorflow.js library 
import * as tf from "@tensorflow/tfjs"
  
// Defining float values
var val = [0.5, 1.5, .66];
  
// Calling tensor1d method
const y = tf.tensor1d(val);
  
// Calling logSigmoid() method
var res = tf.logSigmoid(y)
  
// Printing output
res.print();


Output:

Tensor
    [-0.474077, -0.2014133, -0.4166367]
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments