Tensorflow.js是Google开发的开源库,用于在浏览器或节点环境中运行机器学习模型和深度学习神经网络。
tf.metrics.recall() 函数用于计算关于标签的预测的召回率。 “召回”是机器学习的指标之一。你可以在这里读更多关于它的内容。
用法:
tf.metrics.recall (yTrue, yPred)
参数:
- yTrue (tensor):它包含 0 或 1 的真值。
- yPred (tensor):它只包含 0 或 1 的预测值。
返回值:它返回一个张量(tf.tensor)。
范例1:
Javascript
const tf = require("@tensorflow/tfjs")
// Creating 2-D tensor of true values
const yTrue = tf.tensor2d([
[0, 0, 1, 1],
[0, 1, 0, 0],
[0, 0, 0, 1]
]);
// Creating 2-D tensor of predicted values
const yPred = tf.tensor2d([
[1, 0, 0, 1],
[0, 1, 0, 0],
[1, 0, 1, 1]
]);
// Getting the result from the recall function
const recallResult = tf.metrics.recall(yTrue, yPred);
recallResult.print();
输出:
Tensor 0.75
范例2:
Javascript
const tf = require("@tensorflow/tfjs")
// Creating 2-D tensor of true values
const trueValues = tf.tensor2d([
[0, 0, 0],
[1, 0, 0],
[0, 1, 0]
]);
// Creating 2-D tensor of predicted values
const predValues = tf.tensor2d([
[0, 1, 0],
[0, 0, 1],
[0, 1, 1]
]);
// Getting the result from the recall function
const recallResult = tf.metrics.recall(trueValues, predValues);
recallResult.print();
输出:
Tensor 0.5
参考: https://js.tensorflow.org/api/latest/#metrics.recall
相关用法
- 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()用法及代码示例
- PHP cal_to_jd()用法及代码示例
- d3.js d3.bisectLeft()用法及代码示例
注:本文由纯净天空筛选整理自parasmadan15大神的英文原创作品 Tensorflow.js tf.metrics.recall() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。