codecamp

TensorFlow函数教程:tf.nn.log_uniform_candidate_sampler

tf.nn.log_uniform_candidate_sampler函数

tf.nn.log_uniform_candidate_sampler(
    true_classes,
    num_true,
    num_sampled,
    unique,
    range_max,
    seed=None,
    name=None
)

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

请参阅指南:神经网络>候选采样

使用log-uniform(Zipfian)基本分布对一组类进行采样.

该操作从整数范围[0, range_max)中随机采样一个采样类(sampled_candidates)的张量.

sampled_candidates的元素从基础分布中不使用替换(if unique=True)或使用替换(if unique=False)来绘制.

此操作的基本分布是近似log-uniform或Zipfian分布:

P(class) = (log(class + 2) - log(class + 1)) / log(range_max + 1)

当目标类大致遵循这样的分布时,此采样器很有用 - 例如,如果类表示按频率降序排序的词典中的单词.如果您的类没有按降低频率排序,请不要使用此操作.

此外,此操作返回张量true_expected_count和sampled_expected_count,表示每个目标类(true_classes)和采样类(sampled_candidates)预期在平均张量的采样类中出现的次数.如果unique=True,则这些是拒绝后概率,我们大致计算它们.

参数:

  • true_classes:一个Tensor,类型为int64,shape为[batch_size, num_true].目标类.
  • num_true:int.每个训练示例的目标类数.
  • num_sampled:int.随机采样的类数.
  • unique:bool.确定批处理中的所有采样类是否都是唯一的.
  • range_max:int.可能的类数.
  • seed:int.特定于操作的seed.默认值为0.
  • name:操作的名称(可选).

返回:

  • sampled_candidates:类型为int64和shape为[num_sampled]的Tensor.抽样类.
  • true_expected_count:类型为float的Tensor.其shape与true_classes相同.每个true_classes的采样分布下的预期计数.
  • sampled_expected_count:张量类型float.形状相同sampled_candidates.每个sampled_candidates的采样分布下的预期计数.
TensorFlow函数教程:tf.nn.log_softmax
TensorFlow函数教程:tf.nn.max_pool
温馨提示
下载编程狮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; }