Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
dòng chảy căng:: ôi:: Tất cả ứng viên lấy mẫu
#include <candidate_sampling_ops.h>
Tạo nhãn để lấy mẫu ứng viên bằng cách phân phối unigram đã học.
Bản tóm tắt
Xem phần giải thích về việc lấy mẫu ứng viên và các định dạng dữ liệu tại go/candidate-sampling.
Đối với mỗi lô, hoạt động này chọn một tập hợp các nhãn ứng cử viên được lấy mẫu.
Ưu điểm của việc lấy mẫu ứng viên theo từng đợt là tính đơn giản và khả năng nhân ma trận dày đặc hiệu quả. Điểm bất lợi là các ứng cử viên được lấy mẫu phải được chọn độc lập với bối cảnh và các nhãn thực sự.
Lập luận:
- phạm vi: Một đối tượng Phạm vi
- true_classes: Ma trận batch_size * num_true, trong đó mỗi hàng chứa ID của num_true target_classes trong nhãn gốc tương ứng.
- num_true: Số lượng nhãn thực cho mỗi ngữ cảnh.
- num_sampled: Số lượng ứng viên cần sản xuất.
- duy nhất: Nếu duy nhất là đúng, chúng tôi lấy mẫu từ chối, sao cho tất cả các ứng cử viên được lấy mẫu trong một đợt là duy nhất. Điều này đòi hỏi một số phép tính gần đúng để ước tính xác suất lấy mẫu sau loại bỏ.
Thuộc tính tùy chọn (xem Attrs
):
- hạt giống: Nếu hạt giống hoặc hạt giống2 được đặt khác 0, bộ tạo số ngẫu nhiên sẽ được gieo hạt giống đã cho. Nếu không, nó sẽ được gieo bởi một hạt giống ngẫu nhiên.
- Seed2: Hạt giống thứ hai để tránh va chạm hạt giống.
Trả về:
-
Output
sampled_candidates: Một vectơ có độ dài bằng số_sampled, trong đó mỗi phần tử là ID của một ứng cử viên được lấy mẫu. -
Output
true_expected_count: Ma trận batch_size * num_true, biểu thị số lần mỗi ứng viên dự kiến xuất hiện trong một loạt ứng viên được lấy mẫu. Nếu duy nhất=true thì đây là một xác suất. -
Output
sampled_expected_count: Một vectơ có độ dài bằng num_sampled, cho mỗi ứng viên được lấy mẫu biểu thị số lần ứng viên dự kiến xuất hiện trong một loạt ứng viên được lấy mẫu. Nếu duy nhất=true thì đây là một xác suất.
Các hàm tĩnh công khai |
---|
Seed (int64 x) | |
Seed2 (int64 x) | |
Thuộc tính công khai
Chức năng công cộng
Các hàm tĩnh công khai
Hạt giống
Attrs Seed(
int64 x
)
Hạt giống2
Attrs Seed2(
int64 x
)
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# tensorflow::ops::AllCandidateSampler Class Reference\n\ntensorflow::ops::AllCandidateSampler\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.3/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 produce.\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\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/all-candidate-sampler/attrs#structtensorflow_1_1ops_1_1_all_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.3/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.3/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.3/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| [AllCandidateSampler](#classtensorflow_1_1ops_1_1_all_candidate_sampler_1aad2d9e73a8fc9a50a37699e20ebffa6a)`(const ::`[tensorflow::Scope](/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` true_classes, int64 num_true, int64 num_sampled, bool unique)` ||\n| [AllCandidateSampler](#classtensorflow_1_1ops_1_1_all_candidate_sampler_1ad1521c027811f7f0e056b87d12071a4e)`(const ::`[tensorflow::Scope](/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` true_classes, int64 num_true, int64 num_sampled, bool unique, const `[AllCandidateSampler::Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/all-candidate-sampler/attrs#structtensorflow_1_1ops_1_1_all_candidate_sampler_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_all_candidate_sampler_1a7cec3217c7f1b8bd521a0f7b8e1b93ff) | [Operation](/versions/r2.3/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [sampled_candidates](#classtensorflow_1_1ops_1_1_all_candidate_sampler_1a47ac61dc358107667c422fccbdd3418d) | `::`[tensorflow::Output](/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [sampled_expected_count](#classtensorflow_1_1ops_1_1_all_candidate_sampler_1a53a987bbc8c5b035948259ba9c90aa20) | `::`[tensorflow::Output](/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [true_expected_count](#classtensorflow_1_1ops_1_1_all_candidate_sampler_1ac46a1428d3dc734892084c568c632d09) | `::`[tensorflow::Output](/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public static functions ||\n|----------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Seed](#classtensorflow_1_1ops_1_1_all_candidate_sampler_1a4ab278d6ad3303f8d03b47ce43637cf5)`(int64 x)` | [Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/all-candidate-sampler/attrs#structtensorflow_1_1ops_1_1_all_candidate_sampler_1_1_attrs) |\n| [Seed2](#classtensorflow_1_1ops_1_1_all_candidate_sampler_1a412dc3eb4a931969a4cd51ca7837131f)`(int64 x)` | [Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/all-candidate-sampler/attrs#structtensorflow_1_1ops_1_1_all_candidate_sampler_1_1_attrs) |\n\n| ### Structs ||\n|-----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::AllCandidateSampler::Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/all-candidate-sampler/attrs) | Optional attribute setters for [AllCandidateSampler](/versions/r2.3/api_docs/cc/class/tensorflow/ops/all-candidate-sampler#classtensorflow_1_1ops_1_1_all_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### AllCandidateSampler\n\n```gdscript\n AllCandidateSampler(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input true_classes,\n int64 num_true,\n int64 num_sampled,\n bool unique\n)\n``` \n\n### AllCandidateSampler\n\n```gdscript\n AllCandidateSampler(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input true_classes,\n int64 num_true,\n int64 num_sampled,\n bool unique,\n const AllCandidateSampler::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```"]]