Skip to content
Related Articles

Related Articles

Tensorflow.js tf.enableDebugMode() Function

Improve Article
Save Article
  • Last Updated : 18 Aug, 2021
Improve Article
Save Article

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


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!