Wednesday, January 8, 2025
Google search engine
HomeLanguagesJavascriptTensorflow.js tf.initializers.zeros() Function

Tensorflow.js tf.initializers.zeros() 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 tf.initializers.zeros() function is an initializer that is used to produce tensors that are initialized to zero.

Syntax:

tf.initializers.zeros()

Parameters: This method does not accept any parameter.

Return Value: It returns zeros.

Example 1:

Javascript




// Importing the tensorflow.Js library
import * as tf from "@tensorflow/tfjs"
  
// Calling tf.initializers.zeros() function
const initializer = tf.initializers.zeros();
  
// Printing output
console.log(JSON.stringify(+initializer));


Output:

null

Example 2:

Javascript




// Importing the tensorflow.Js library
import * as tf from "@tensorflow/tfjs"
  
// Calling tf.initializers.zeros() function
const initializer = tf.initializers.zeros();
  
// Defining shape and dtype w.r.t initializer
const x = initializer.shape = [ [1, 2], [3, 5]];
const y = initializer.dtype = 'int32';
  
// Printing output
console.log(initializer);
console.log(JSON.stringify(+initializer));


Output:

{
  "shape": [
    [
      1,
      2
    ],
    [
      3,
      5
    ]
  ],
  "dtype": "int32"
}
null

Reference: https://js.tensorflow.org/api/latest/#initializers.zeros

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