Saturday, October 5, 2024
Google search engine
HomeLanguagesJavascriptTensorflow.js tf.localResponseNormalization() Function

Tensorflow.js tf.localResponseNormalization() 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 .localResponseNormalization() function is used to standardize the stimulation connected with a local neighborhood through or inside the channels.

Syntax:

tf.localResponseNormalization (x, depthRadius?, bias?, alpha?, beta?)

Parameters:  

  • x: It is the stated input tensor. Where, the 4D input tensor is considered just as a 3D array in referenceto 1D vectors with the utmost size. Furthermore, each and every vector is standardize individually. It can be of type tf.Tensor3D, tf.Tensor4D, TypedArray, or an array.
  • depthRadius: It is the stated count of side by side channels in the standardization of 1D window. It is optional and it is of type number.
  • bias: It is the constant stated bias expression for the base. It is optional and is of type number.
  • alpha: It is the stated scale factor that is in general positive. It is optional and is of type number.
  • beta: It is the stated exponent which is optional and is of type number.

Return Value: It returns tf.Tensor3D, or tf.Tensor4D.

Example 1:

Javascript




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Defining tf.tensor3d input
const x = tf.tensor3d([1, 2, 3, 4, 6, 6], [1, 2, 3]);
  
// Calling tf.localResponseNormalization() method
// and printing output
x.localResponseNormalization().print();


Output:

Tensor
    [[[0.2581989, 0.5163978, 0.7745967],
      [0.4239992, 0.6359987, 0.6359987]]]

Example 2:

Javascript




// Importing the tensorflow.js library
// import * as tf from "@tensorflow/tfjs"
  
// Calling tf.localResponseNormalization() method
// and printing output
tf.localResponseNormalization(
    tf.tensor3d([1.1, 3.2, -3, null, 5, 0], 
    [1, 1, 6]), 4, 3, 2, 1).print();  


Output:

Tensor
     [ [[0.0117146, 0.0340788, -0.0319489, 0, 0.0532481, 0],]]

Reference: https://js.tensorflow.org/api/latest/#localResponseNormalization

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