Tensorflow.js是由Google开发的开源库,用于在浏览器或节点环境中运行机器学习模型以及深度学习神经网络。
.fetch() 函数用于返回一个平台专用的 fetch 操作。此外,如果 fetch 指定为与全局对象(即窗口、进程等)联系,则 tf.util.fetch 返回该函数,否则返回平台专用说明。
用法:
tf.fetch(path, requestInits?)
参数:
- path:它是字符串类型的声明路径。
- requestInits:声明的RequestInit。它是可选的并且是字符串类型。
返回值:它返回响应的承诺。
范例1:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Calling fetch() method with respect
// to global
const res = tf.env().global.fetch(
'https://js.tensorflow.org/api/latest/#tf.Sequential.evaluateDataset');
// Printing output
console.log(res);
输出:
[object Response]
范例2:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Calling fetch() method
const res = await tf.util.fetch(
'https://js.tensorflow.org/api/latest/#fetch');
// Printing output
console.log(JSON.stringify(res));
输出:
{}
相关用法
- PHP imagecreatetruecolor()用法及代码示例
- p5.js year()用法及代码示例
- d3.js d3.utcTuesdays()用法及代码示例
- PHP ImagickDraw getTextAlignment()用法及代码示例
- PHP Ds\Sequence last()用法及代码示例
- PHP Imagick floodFillPaintImage()用法及代码示例
- PHP geoip_continent_code_by_name()用法及代码示例
- d3.js d3.map.set()用法及代码示例
- PHP GmagickPixel setcolor()用法及代码示例
- Tensorflow.js tf.layers.embedding()用法及代码示例
- PHP opendir()用法及代码示例
- d3.js d3.bisectLeft()用法及代码示例
注:本文由纯净天空筛选整理自nidhi1352singh大神的英文原创作品 Tensorflow.js tf.fetch() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。