Tensorflow.js tf.enableProdMode() 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 .enableProdMode() function is used to enable the mode of production that deactivates the exactness restraints in support of the production.
Syntax:
tf.enableProdMode()
Parameters: This method does not hold any parameter.
Return Value: It returns void.
Example 1:
Javascript
import * as tf from "@tensorflow/tfjs"
await tf.enableProdMode();
tf.env().set( 'DEBUG' , false );
console.log(tf.env().flags);
|
Output:
{
"IS_BROWSER": true,
"IS_NODE": false,
"DEBUG": false,
"CPU_HANDOFF_SIZE_THRESHOLD": 128,
"PROD": true,
"WEBGL_VERSION": 2,
"HAS_WEBGL": true,
"WEBGL_CHECK_NUMERICAL_PROBLEMS": false,
"IS_TEST": false,
"WEBGL_CPU_FORWARD": true,
"WEBGL_MAX_TEXTURE_SIZE": 16384,
"WEBGL_FORCE_F16_TEXTURES": true,
"WEBGL_RENDER_FLOAT32_CAPABLE": true,
"WEBGL_RENDER_FLOAT32_ENABLED": true,
"WEBGL_FLUSH_THRESHOLD": -1,
"WEBGL_PACK": true,
"WEBGL_LAZILY_UNPACK": true,
"WEBGL_DELETE_TEXTURE_THRESHOLD": -1,
"WEBGL_PACK_BINARY_OPERATIONS": true,
"WEBGL_USE_SHAPES_UNIFORMS": false,
"WEBGL_PACK_UNARY_OPERATIONS": true,
"WEBGL_DOWNLOAD_FLOAT_ENABLED": true,
"WEBGL_CONV_IM2COL": true,
"WEBGL_PACK_DEPTHWISECONV": true,
"WEBGL_MAX_TEXTURES_IN_SHADER": 16,
"WEBGL_PACK_ARRAY_OPERATIONS": true
}
Example 2:
Javascript
import * as tf from "@tensorflow/tfjs"
await tf.enableProdMode();
tf.env().set( "PROD" , !0)
tf.env().set( 'WEBGL_FORCE_F16_TEXTURES' , false );
await tf.ready();
console.log(tf.env().features);
|
Output:
{
"IS_BROWSER": true,
"IS_NODE": false,
"DEBUG": false,
"CPU_HANDOFF_SIZE_THRESHOLD": 128,
"PROD": true,
"WEBGL_VERSION": 2,
"HAS_WEBGL": true,
"WEBGL_CHECK_NUMERICAL_PROBLEMS": false,
"IS_TEST": false,
"WEBGL_CPU_FORWARD": true,
"WEBGL_MAX_TEXTURE_SIZE": 16384,
"WEBGL_FORCE_F16_TEXTURES": false,
"WEBGL_RENDER_FLOAT32_CAPABLE": true,
"WEBGL_RENDER_FLOAT32_ENABLED": true,
"WEBGL_FLUSH_THRESHOLD": -1,
"WEBGL_PACK": true,
"WEBGL_LAZILY_UNPACK": true,
"WEBGL_DELETE_TEXTURE_THRESHOLD": -1,
"WEBGL_PACK_BINARY_OPERATIONS": true,
"WEBGL_USE_SHAPES_UNIFORMS": false,
"WEBGL_PACK_UNARY_OPERATIONS": true,
"WEBGL_DOWNLOAD_FLOAT_ENABLED": true,
"WEBGL_CONV_IM2COL": true,
"WEBGL_PACK_DEPTHWISECONV": true,
"WEBGL_MAX_TEXTURES_IN_SHADER": 16,
"WEBGL_PACK_ARRAY_OPERATIONS": true
}
Reference: https://js.tensorflow.org/api/latest/#enableProdMode
Last Updated :
14 Aug, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...