Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Tensorflow.js tf.localResponseNormalization() Function

  • Last Updated : 24 Jun, 2021

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!