Saturday, December 28, 2024
Google search engine
HomeLanguagesJavascriptTensorflow.js tf.enableDebugMode() Function

Tensorflow.js tf.enableDebugMode() 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 .enableDebugMode() function is used to enable the debug mode that would register data regarding every single executed kernels i.e. the runout time of the kernel implementation, including the rank, size, as well as shape of the resultant tensor.

Note:

  • The Debug mode would substantially reduce the speed of our software because it would download the end result of every single action within the CPU which must not be utilized in the production.
  • The Debug mode would not impact the timing data of the kernel performance as the download time here is not assessed in the kernel performance time.

Syntax:

tf.enableDebugMode() 

Parameters:  This method does not hold any parameter.

Return Value: It returns void.

Example 1:

Javascript




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Calling enableDebugMode() method
await tf.enableDebugMode();
  
// Setting prod mode of the
// environment
tf.env().set('PROD', false);
  
// Printing output
console.log(tf.env().flags);


Output:

{
  "IS_BROWSER": true,
  "IS_NODE": false,
  "DEBUG": true,
  "CPU_HANDOFF_SIZE_THRESHOLD": 128,
  "PROD": false
}

Example 2:

Javascript




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Calling enableDebugMode() method
await tf.enableDebugMode();
  
// Setting debug mode of the environment
tf.env().set("DEBUG", !0)
  
// Setting textures of the environment
tf.env().set('WEBGL_FORCE_F16_TEXTURES', true);
  
// Calling ready() method
await tf.ready();
  
// Printing output
console.log(tf.env().features);


Output:

{
  "IS_BROWSER": true,
  "IS_NODE": false,
  "DEBUG": true,
  "CPU_HANDOFF_SIZE_THRESHOLD": 128,
  "PROD": true,
  "WEBGL_FORCE_F16_TEXTURES": true,
  "WEBGL_VERSION": 2,
  "HAS_WEBGL": true
}

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

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