Open In App

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:

Syntax:



tf.enableDebugMode() 

Parameters:  This method does not hold any parameter.

Return Value: It returns void.

Example 1:




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




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


Article Tags :