tensorflow :: ops :: FixedUnigramCandidateSampler
#include <candidate_sampling_ops.h>
学習したユニグラム分布を使用して、候補サンプリングのラベルを生成します。
概要
ユニグラムサンプラーは、データからその場で分布を構築する代わりに、ファイルから読み取られた、またはメモリ内配列として渡された固定ユニグラム分布を使用できます。重みに歪みパワーを適用することにより、分布を歪めるオプションもあります。
語彙ファイルはCSVのような形式である必要があり、最後のフィールドは単語に関連付けられた重みです。
この操作では、バッチごとに、サンプリングされた候補ラベルの単一のセットが選択されます。
バッチごとに候補をサンプリングすることの利点は、単純さと効率的な密行列乗算の可能性です。欠点は、サンプリングされた候補をコンテキストや実際のラベルとは無関係に選択する必要があることです。
引数:
- スコープ:スコープオブジェクト
- true_classes:batch_size * num_trueマトリックス。各行には、対応する元のラベルのnum_truetarget_classesのIDが含まれます。
- num_true:コンテキストごとの真のラベルの数。
- num_sampled:ランダムにサンプリングする候補の数。
- unique:uniqueがtrueの場合、バッチ内のすべてのサンプリングされた候補が一意になるように、拒否してサンプリングします。これには、棄却後のサンプリング確率を推定するための近似が必要です。
- range_max:サンプラーは間隔[0、range_max)から整数をサンプリングします。
オプションの属性(参照Attrs
):
- vocab_file:このファイルの各有効行(CSVのような形式である必要があります)は、有効な単語IDに対応します。 IDは、num_reserved_idsから順番に並んでいます。各行の最後のエントリは、カウントまたは相対確率に対応する値であることが期待されます。 vocab_fileとunigramのいずれか1つをこのopに渡す必要があります。
- 歪み:歪みは、ユニグラム確率分布を歪めるために使用されます。各重みは、内部ユニグラム分布に追加する前に、まず歪みの累乗になります。その結果、歪み= 1.0は(語彙ファイルで定義されているように)通常のユニグラムサンプリングを提供し、歪み= 0.0は一様分布を提供します。
- num_reserved_ids:オプションで、いくつかの予約済みIDを[0、...、num_reserved_ids)の範囲でユーザーが追加できます。 1つの使用例は、特別な未知の単語トークンがID 0として使用されることです。これらのIDのサンプリング確率は、0になります。
- num_shards:サンプラーを使用して、元の範囲のサブセットからサンプリングし、並列処理によって計算全体を高速化できます。このパラメーター(「shard」とともに)は、計算全体で使用されているパーティションの数を示します。
- シャード:サンプラーを使用して、元の範囲のサブセットからサンプリングし、並列処理によって計算全体を高速化できます。このパラメーター( 'num_shards'と共に)は、パーティショニングが使用されている場合のサンプラー操作の特定のパーティション番号を示します。
- ユニグラム:ユニグラムのカウントまたは確率のリスト。IDごとに1つずつ順番に表示されます。 vocab_fileとunigramのいずれか1つをこのopに渡す必要があります。
- seed:seedまたはseed2のいずれかがゼロ以外に設定されている場合、乱数ジェネレーターは指定されたシードによってシードされます。それ以外の場合は、ランダムシードによってシードされます。
- seed2:シードの衝突を回避するための2番目のシード。
戻り値:
-
Output
sampled_candidates:長さnum_sampledのベクトル。各要素は、サンプリングされた候補のIDです。 -
Output
true_expected_count:batch_size * num_true行列。これは、サンプリングされた候補のバッチで各候補が発生すると予想される回数を表します。 unique = trueの場合、これは確率です。 -
Output
sampled_expected_count:サンプリングされた候補のバッチで候補が発生すると予想される回数を表す、サンプリングされた候補ごとの長さnum_sampledのベクトル。 unique = trueの場合、これは確率です。
コンストラクタとデストラクタ | |
---|---|
FixedUnigramCandidateSampler (const :: tensorflow::Scope & scope, :: tensorflow::Input true_classes, int64 num_true, int64 num_sampled, bool unique, int64 range_max) | |
FixedUnigramCandidateSampler (const :: tensorflow::Scope & scope, :: tensorflow::Input true_classes, int64 num_true, int64 num_sampled, bool unique, int64 range_max, const FixedUnigramCandidateSampler::Attrs & attrs) |
パブリック属性 | |
---|---|
operation | |
sampled_candidates | |
sampled_expected_count | |
true_expected_count |
パブリック静的関数 | |
---|---|
Distortion (float x) | |
NumReservedIds (int64 x) | |
NumShards (int64 x) | |
Seed (int64 x) | |
Seed2 (int64 x) | |
Shard (int64 x) | |
Unigrams (const gtl::ArraySlice< float > & x) | |
VocabFile (StringPiece x) |
構造体 | |
---|---|
tensorflow :: ops :: FixedUnigramCandidateSampler :: Attrs | FixedUnigramCandidateSamplerのオプションの属性セッター。 |
パブリック属性
操作
Operation operation
sampled_candidates
::tensorflow::Output sampled_candidates
sampled_expected_count
::tensorflow::Output sampled_expected_count
true_expected_count
::tensorflow::Output true_expected_count
公の行事
FixedUnigramCandidateSampler
FixedUnigramCandidateSampler( const ::tensorflow::Scope & scope, ::tensorflow::Input true_classes, int64 num_true, int64 num_sampled, bool unique, int64 range_max )
FixedUnigramCandidateSampler
FixedUnigramCandidateSampler( const ::tensorflow::Scope & scope, ::tensorflow::Input true_classes, int64 num_true, int64 num_sampled, bool unique, int64 range_max, const FixedUnigramCandidateSampler::Attrs & attrs )
パブリック静的関数
ねじれ
Attrs Distortion( float x )
NumReservedIds
Attrs NumReservedIds( int64 x )
NumShards
Attrs NumShards( int64 x )
シード
Attrs Seed( int64 x )
Seed2
Attrs Seed2( int64 x )
シャード
Attrs Shard( int64 x )
ユニグラム
Attrs Unigrams( const gtl::ArraySlice< float > & x )
VocabFile
Attrs VocabFile( StringPiece x )