จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เทนเซอร์โฟลว์:: ปฏิบัติการ:: LearnedUnigramCandidateSampler
#include <candidate_sampling_ops.h>
สร้างป้ายกำกับสำหรับการสุ่มตัวอย่างผู้สมัครด้วยการแจกแจงแบบยูนิแกรมที่เรียนรู้
สรุป
ดูคำอธิบายของการสุ่มตัวอย่างผู้สมัครและรูปแบบข้อมูลที่ go/candidate-sampling
สำหรับแต่ละชุด ฝ่ายปฏิบัติการนี้จะเลือกชุดป้ายกำกับตัวอย่างที่สุ่มตัวอย่างชุดเดียว
ข้อดีของการเลือกตัวอย่างต่อชุดคือความเรียบง่ายและความเป็นไปได้ของการคูณเมทริกซ์หนาแน่นอย่างมีประสิทธิภาพ ข้อเสียคือต้องเลือกผู้สมัครตัวอย่างโดยอิสระจากบริบทและป้ายกำกับที่แท้จริง
ข้อโต้แย้ง:
- ขอบเขต: วัตถุ ขอบเขต
- true_classes: เมทริกซ์batch_size * num_true ซึ่งแต่ละแถวมี ID ของ num_true target_classes ในเลเบลต้นฉบับที่เกี่ยวข้อง
- num_true: จำนวนป้ายกำกับที่แท้จริงต่อบริบท
- num_sampled: จำนวนผู้สมัครที่จะสุ่มตัวอย่าง
- ไม่ซ้ำกัน: หากไม่ซ้ำกันเป็นจริง เราจะสุ่มตัวอย่างด้วยการปฏิเสธ เพื่อให้ผู้สมัครสุ่มตัวอย่างทั้งหมดในชุดไม่ซ้ำกัน ซึ่งต้องมีการประมาณเพื่อประเมินความน่าจะเป็นของการสุ่มตัวอย่างหลังการปฏิเสธ
- range_max: ตัวเก็บตัวอย่างจะสุ่มตัวอย่างจำนวนเต็มจากช่วง [0, range_max)
แอ็ตทริบิวต์ทางเลือก (ดู Attrs
):
- เมล็ด: หากเมล็ดใดเมล็ดหนึ่งหรือเมล็ด 2 ถูกตั้งค่าไม่เป็นศูนย์ เครื่องกำเนิดตัวเลขสุ่มจะถูกเพาะโดยเมล็ดที่กำหนด มิฉะนั้นจะถูกเพาะโดยเมล็ดแบบสุ่ม
- seed2: เมล็ดที่สองเพื่อหลีกเลี่ยงการชนกันของเมล็ด
ผลตอบแทน:
-
Output
Sampled_candidates: เวกเตอร์ที่มีความยาว num_sampled ซึ่งแต่ละองค์ประกอบเป็น ID ของตัวเลือกที่สุ่มตัวอย่าง -
Output
true_expected_count: เมทริกซ์ batch_size * num_true ซึ่งแสดงถึงจำนวนครั้งที่ผู้สมัครแต่ละคนคาดว่าจะเกิดขึ้นในชุดของผู้สมัครที่สุ่มตัวอย่าง หากไม่ซ้ำกัน=จริง นี่คือความน่าจะเป็น -
Output
Sampled_expected_count: เวกเตอร์ที่มีความยาว num_sampled สำหรับผู้สมัครที่สุ่มตัวอย่างแต่ละรายการ ซึ่งแสดงถึงจำนวนครั้งที่ผู้สมัครที่คาดว่าจะเกิดขึ้นในชุดของผู้สมัครที่สุ่มตัวอย่าง หากไม่ซ้ำกัน=จริง นี่คือความน่าจะเป็น
ตัวสร้างและผู้ทำลาย |
---|
LearnedUnigramCandidateSampler (const :: tensorflow::Scope & scope, :: tensorflow::Input true_classes, int64 num_true, int64 num_sampled, bool unique, int64 range_max)
|
LearnedUnigramCandidateSampler (const :: tensorflow::Scope & scope, :: tensorflow::Input true_classes, int64 num_true, int64 num_sampled, bool unique, int64 range_max, const LearnedUnigramCandidateSampler::Attrs & attrs) |
ฟังก์ชันคงที่สาธารณะ |
---|
Seed (int64 x) | |
Seed2 (int64 x) | |
คุณลักษณะสาธารณะ
งานสาธารณะ
LearnedUnigramCandidateSampler
LearnedUnigramCandidateSampler(
const ::tensorflow::Scope & scope,
::tensorflow::Input true_classes,
int64 num_true,
int64 num_sampled,
bool unique,
int64 range_max
)
ฟังก์ชันคงที่สาธารณะ
เมล็ดพันธุ์
Attrs Seed(
int64 x
)
เมล็ดพันธุ์2
Attrs Seed2(
int64 x
)
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[null,null,["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# tensorflow::ops::LearnedUnigramCandidateSampler Class Reference\n\ntensorflow::ops::LearnedUnigramCandidateSampler\n===============================================\n\n`#include \u003ccandidate_sampling_ops.h\u003e`\n\nGenerates labels for candidate sampling with a learned unigram distribution.\n\nSummary\n-------\n\nSee explanations of candidate sampling and the data formats at go/candidate-sampling.\n\nFor each batch, this op picks a single set of sampled candidate labels.\n\nThe advantages of sampling candidates per-batch are simplicity and the possibility of efficient dense matrix multiplication. The disadvantage is that the sampled candidates must be chosen independently of the context and of the true labels.\n\nArguments:\n\n- scope: A [Scope](/versions/r2.1/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- true_classes: A batch_size \\* num_true matrix, in which each row contains the IDs of the num_true target_classes in the corresponding original label.\n- num_true: Number of true labels per context.\n- num_sampled: Number of candidates to randomly sample.\n- unique: If unique is true, we sample with rejection, so that all sampled candidates in a batch are unique. This requires some approximation to estimate the post-rejection sampling probabilities.\n- range_max: The sampler will sample integers from the interval \\[0, range_max).\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r2.1/api_docs/cc/struct/tensorflow/ops/learned-unigram-candidate-sampler/attrs#structtensorflow_1_1ops_1_1_learned_unigram_candidate_sampler_1_1_attrs)):\n\n- seed: If either seed or seed2 are set to be non-zero, the random number generator is seeded by the given seed. Otherwise, it is seeded by a random seed.\n- seed2: An second seed to avoid seed collision.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) sampled_candidates: A vector of length num_sampled, in which each element is the ID of a sampled candidate.\n- [Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) true_expected_count: A batch_size \\* num_true matrix, representing the number of times each candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.\n- [Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) sampled_expected_count: A vector of length num_sampled, for each sampled candidate representing the number of times the candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [LearnedUnigramCandidateSampler](#classtensorflow_1_1ops_1_1_learned_unigram_candidate_sampler_1a7c50027fcf319a0ac7abcc8af2d8861a)`(const ::`[tensorflow::Scope](/versions/r2.1/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.1/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` true_classes, int64 num_true, int64 num_sampled, bool unique, int64 range_max)` ||\n| [LearnedUnigramCandidateSampler](#classtensorflow_1_1ops_1_1_learned_unigram_candidate_sampler_1aaddf15821aae74450fc3b415e18376a9)`(const ::`[tensorflow::Scope](/versions/r2.1/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.1/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` true_classes, int64 num_true, int64 num_sampled, bool unique, int64 range_max, const `[LearnedUnigramCandidateSampler::Attrs](/versions/r2.1/api_docs/cc/struct/tensorflow/ops/learned-unigram-candidate-sampler/attrs#structtensorflow_1_1ops_1_1_learned_unigram_candidate_sampler_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|----------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_learned_unigram_candidate_sampler_1a446093e6e23377b91e9335fb0b762ef7) | [Operation](/versions/r2.1/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [sampled_candidates](#classtensorflow_1_1ops_1_1_learned_unigram_candidate_sampler_1a590ac067c5a83a4dba8105564bc56b88) | `::`[tensorflow::Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [sampled_expected_count](#classtensorflow_1_1ops_1_1_learned_unigram_candidate_sampler_1ab7da3d1ba0800e7229aedb76fafaae7b) | `::`[tensorflow::Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [true_expected_count](#classtensorflow_1_1ops_1_1_learned_unigram_candidate_sampler_1a91c0061329f572532d581b4175a2a8c6) | `::`[tensorflow::Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public static functions ||\n|----------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Seed](#classtensorflow_1_1ops_1_1_learned_unigram_candidate_sampler_1a7993b832d420f9ac8835e0070689ea0d)`(int64 x)` | [Attrs](/versions/r2.1/api_docs/cc/struct/tensorflow/ops/learned-unigram-candidate-sampler/attrs#structtensorflow_1_1ops_1_1_learned_unigram_candidate_sampler_1_1_attrs) |\n| [Seed2](#classtensorflow_1_1ops_1_1_learned_unigram_candidate_sampler_1a043a0a13bbd736a96b60b0a030061638)`(int64 x)` | [Attrs](/versions/r2.1/api_docs/cc/struct/tensorflow/ops/learned-unigram-candidate-sampler/attrs#structtensorflow_1_1ops_1_1_learned_unigram_candidate_sampler_1_1_attrs) |\n\n| ### Structs ||\n|----------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::LearnedUnigramCandidateSampler::Attrs](/versions/r2.1/api_docs/cc/struct/tensorflow/ops/learned-unigram-candidate-sampler/attrs) | Optional attribute setters for [LearnedUnigramCandidateSampler](/versions/r2.1/api_docs/cc/class/tensorflow/ops/learned-unigram-candidate-sampler#classtensorflow_1_1ops_1_1_learned_unigram_candidate_sampler). |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### sampled_candidates\n\n```scdoc\n::tensorflow::Output sampled_candidates\n``` \n\n### sampled_expected_count\n\n```scdoc\n::tensorflow::Output sampled_expected_count\n``` \n\n### true_expected_count\n\n```scdoc\n::tensorflow::Output true_expected_count\n``` \n\nPublic functions\n----------------\n\n### LearnedUnigramCandidateSampler\n\n```gdscript\n LearnedUnigramCandidateSampler(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input true_classes,\n int64 num_true,\n int64 num_sampled,\n bool unique,\n int64 range_max\n)\n``` \n\n### LearnedUnigramCandidateSampler\n\n```gdscript\n LearnedUnigramCandidateSampler(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input true_classes,\n int64 num_true,\n int64 num_sampled,\n bool unique,\n int64 range_max,\n const LearnedUnigramCandidateSampler::Attrs & attrs\n)\n``` \n\nPublic static functions\n-----------------------\n\n### Seed\n\n```text\nAttrs Seed(\n int64 x\n)\n``` \n\n### Seed2\n\n```text\nAttrs Seed2(\n int64 x\n)\n```"]]