Tensorflow.js tf.env() 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 .env() function is used to return the present environment i.e. a global entity. Moreover, the environment object includes the assessed attribute values along with the dynamic platform.
Syntax:
tf.env()
Parameters: This method do not holds any parameter.
Return Value: It returns tf.Environment.
Example 1:
Javascript
// Importing the tensorflow.js libraryimport * as tf from "@tensorflow/tfjs" // Calling env() and getBool() method// along with its parameterconst res = tf.env().getBool('WEBGL_RENDER_FLOAT32_ENABLED'); // Printing outputconsole.log(res); |
Output:
true
Example 2:
Javascript
// Importing the tensorflow.js libraryimport * as tf from "@tensorflow/tfjs" // Calling env() method's featureconst res1 = tf.env().features; // Printing outputconsole.log(res1); |
Output:
{
"WEBGL_FORCE_F16_TEXTURES": false,
"WEBGL_VERSION": 2,
"WEBGL_RENDER_FLOAT32_CAPABLE": true,
"WEBGL_RENDER_FLOAT32_ENABLED": true,
"PROD": true,
"DEBUG": true
}Reference: https://js.tensorflow.org/api/latest/#env


