codecamp

multinomial函数:从多项式分布中抽取样本

tf.multinomial 函数
multinomial(
    logits,
    num_samples,
    seed=None,
    name=None
)

定义在:tensorflow/python/ops/random_ops.py.

参见指南:生成常量,序列和随机值>随机张量

从多项式分布中抽取样本.

例:

# 样本具有形状 [1,5],其中每个值是 0 或 1,具有相等的概率.
samples = tf.multinomial(tf.log([[10., 10.]]), 5)

参数:

  • logits:形状为 [batch_size, num_classes] 的二维张量;每个切片:[i, :] 表示所有类的非标准化对数概率.
  • num_samples:0维张量.为每行切片绘制的独立样本数.
  • seed:Python 整数.用于为分发创建一个随机种子.你可以查看 tf.set_random_seed 操作.
  • name:操作的可选名称.

返回值:

返回绘制样品的形状 [batch_size, num_samples].

TensorFlow变量:tf.min_max_variable_partitioner
TensorFlow构建图形:tf.name_scope函数
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }