当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


Tensorflow.js tf.env()用法及代码示例

Tensorflow.js是由Google开发的开源库,用于在浏览器或节点环境中运行机器学习模型以及深度学习神经网络。

.env() 函数用于返回当前环境,即全局实体。此外,环境对象包括评估的属性值以及动态平台。

用法:

tf.env() 

参数:此方法不保存任何参数。

返回值:它返回 tf.Environment。



范例1:

Javascript


// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Calling env() and getBool() method
// along with its parameter
const res = tf.env().getBool('WEBGL_RENDER_FLOAT32_ENABLED');
  
// Printing output
console.log(res);

输出:

true

范例2:

Javascript


// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Calling env() method's feature
const res1 = tf.env().features;
  
// Printing output
console.log(res1);

输出:

{
  "WEBGL_FORCE_F16_TEXTURES":false,
  "WEBGL_VERSION":2,
  "WEBGL_RENDER_FLOAT32_CAPABLE":true,
  "WEBGL_RENDER_FLOAT32_ENABLED":true,
  "PROD":true,
  "DEBUG":true
}

参考: https://js.tensorflow.org/api/latest/#env

相关用法


注:本文由纯净天空筛选整理自nidhi1352singh大神的英文原创作品 Tensorflow.js tf.env() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。