Tensorflow.js是由Google开发的开源库,用于在浏览器或节点环境中运行机器学习模型以及深度学习神经网络。
.multinomial() 函数用于生成 tf.Tensor 以及从多项式分布中拖出的输入。
用法:
tf.multinomial(logits, numSamples, seed?, normalized?)
Parameters:
- logits:它是一个声明的一维数组以及杂乱无章的对数期望,或者是一个形状为 [batchSize, numOutcomes] 的二维数组,它可以是 tf.Tensor1D、tf.Tensor2D、TypedArray 或 Array 类型。
- numSamples:它是为每个行部分拖动的规定样本数。它是类型号。
- seed:它是规定的种子编号,是编号类型的可选参数。
- normalized:它检查给定的 logits 是否组织了真正的期望值,即(总和为 1)。默认值为 false,是 Boolean 类型的可选参数。
返回值:它返回 tf.Tensor1D 或 tf.Tensor2D。
范例1:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Defining logits
const logits = tf.tensor([35, 158]);
// Calling tf.multinomial() method and
// Printing output
tf.multinomial(logits, 4).print();
输出:
Tensor [1, 1, 1, 1]
范例2:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Calling tf.multinomial() method and
// Printing output
tf.multinomial(tf.tensor(
[5.7, 8.7, NaN, 'a', null, 0]), 6).print();
输出:
Tensor [5, 5, 5, 5, 5, 5]
相关用法
- PHP imagecreatetruecolor()用法及代码示例
- p5.js year()用法及代码示例
- d3.js d3.utcTuesdays()用法及代码示例
- PHP ImagickDraw getTextAlignment()用法及代码示例
- PHP Ds\Sequence last()用法及代码示例
- PHP Imagick floodFillPaintImage()用法及代码示例
- PHP array_udiff_uassoc()用法及代码示例
- PHP geoip_continent_code_by_name()用法及代码示例
- d3.js d3.map.set()用法及代码示例
- PHP GmagickPixel setcolor()用法及代码示例
- PHP opendir()用法及代码示例
- PHP cal_to_jd()用法及代码示例
- d3.js d3.bisectLeft()用法及代码示例
- PHP stream_get_transports()用法及代码示例
注:本文由纯净天空筛选整理自nidhi1352singh大神的英文原创作品 Tensorflow.js tf.multinomial() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。