Open In App

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:  



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

Example 1:




// 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:




// 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

Article Tags :