Open In App

Tensorflow.js tf.layers.gaussianDropout() Function

Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment. It also helps the developers to develop ML models in JavaScript language and can use ML directly in the browser or Node.js.

The tf.layers.gaussianDropout() function is used to apply multiplicative 1 centered Gaussian noise. Since it is a regularization layer hence, it is only active at training time.



tf.layers.gaussianDropout(arguments)

Parameters

Return Value: It returns GaussianDropout.



Example 1:




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
 
// Initializing the tensor
const geek= tf.tensor1d([128561, 1536782, 221343, 781422]);
 
// Reshaping tensor
const geek1 = tf.reshape(geek,[2,2]);
 
// Creating gaussianDropout of poolSize 2*2
const gaussianDropout =
      tf.layers.gaussianDropout({poolSize:[2,2]});
 
// Applying gaussianDropout on geek1 tensor
const result = gaussianDropout.apply(geek1);
 
// Printing the result tensor
result.print();

Output:

Tensor
    [[128561, 1536782],
     [221343, 781422 ]]

Example 2:




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
 
// Reshaping tensor
const geek1 = tf.reshape(
  tf.tensor1d([2125, 1637, 1272, 3268]),
  [2,2]);
 
// Applying gaussianDropout on geek1 tensor
tf.layers.gaussianDropout(
  {
    poolSize:[2,2]
  }
).apply(
  geek1).print();

Output:

Tensor
    [[2125, 1637],
     [1272, 3268]]

Reference: https://js.tensorflow.org/api/3.6.0/#layers.gaussianDropout


Article Tags :