تدفق التوتر:: العمليات:: توبك
#include <nn_ops.h>
يبحث عن قيم ومؤشرات أكبر عناصر k
للبعد الأخير.
ملخص
إذا كان الإدخال متجهًا (المرتبة 1)، فسيتم العثور على أكبر إدخالات k
في المتجه وإخراج قيمها ومؤشراتها كمتجهات. وبالتالي values[j]
هي أكبر مُدخل j
في input
، ومؤشرها هو indices[j]
.
بالنسبة للمصفوفات (المدخلات ذات الرتبة الأعلى)، يتم حساب أعلى إدخالات k
في كل صف (المتجه على طول البعد الأخير). هكذا،
values.shape = indices.shape = input.shape[:-1] + [k]
إذا كان هناك عنصران متساويان، فسيظهر عنصر الفهرس السفلي أولاً.
الحجج:
- النطاق: كائن النطاق
- الإدخال: 1-D أو أعلى مع البعد الأخير على الأقل
k
. - ك: 0-د. عدد العناصر العليا التي يجب البحث عنها على طول البعد الأخير (على طول كل صف للمصفوفات).
السمات الاختيارية (انظر Attrs
):
- تم الفرز: إذا كان صحيحًا، فسيتم فرز عناصر
k
الناتجة حسب القيم بترتيب تنازلي.
العوائد:
- قيم
Output
: أكبر العناصر k
على طول كل شريحة الأبعاد الأخيرة. - مؤشرات
Output
: مؤشرات values
ضمن البعد الأخير input
.
وظائف ثابتة العامة |
---|
Sorted (bool x) | |
الصفات العامة
المؤشرات
::tensorflow::Output indices
عملية
Operation operation
قيم
::tensorflow::Output values
الوظائف العامة
توبك
TopK(
const ::tensorflow::Scope & scope,
::tensorflow::Input input,
::tensorflow::Input k
)
توبك
TopK(
const ::tensorflow::Scope & scope,
::tensorflow::Input input,
::tensorflow::Input k,
const TopK::Attrs & attrs
)
وظائف ثابتة العامة
مرتبة
Attrs Sorted(
bool x
)
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# tensorflow::ops::TopK Class Reference\n\ntensorflow::ops::TopK\n=====================\n\n`#include \u003cnn_ops.h\u003e`\n\nFinds values and indices of the `k` largest elements for the last dimension.\n\nSummary\n-------\n\nIf the input is a vector (rank-1), finds the `k` largest entries in the vector and outputs their values and indices as vectors. Thus `values[j]` is the `j`-th largest entry in `input`, and its index is `indices[j]`.\n\nFor matrices (resp. higher rank input), computes the top `k` entries in each row (resp. vector along the last dimension). Thus, \n\n```cplint\nvalues.shape = indices.shape = input.shape[:-1] + [k]\n```\n\n\u003cbr /\u003e\n\nIf two elements are equal, the lower-index element appears first.\n\nArguments:\n\n- scope: A [Scope](/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- input: 1-D or higher with last dimension at least `k`.\n- k: 0-D. Number of top elements to look for along the last dimension (along each row for matrices).\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/top-k/attrs#structtensorflow_1_1ops_1_1_top_k_1_1_attrs)):\n\n- sorted: If true the resulting `k` elements will be sorted by the values in descending order.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) values: The `k` largest elements along each last dimensional slice.\n- [Output](/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) indices: The indices of `values` within the last dimension of `input`.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [TopK](#classtensorflow_1_1ops_1_1_top_k_1a0c8404c5e20cae7d52b460b213d13bf4)`(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)` input, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` k)` ||\n| [TopK](#classtensorflow_1_1ops_1_1_top_k_1ad55e14f1c8e36a07ae7e3e5189ce1de6)`(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)` input, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` k, const `[TopK::Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/top-k/attrs#structtensorflow_1_1ops_1_1_top_k_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [indices](#classtensorflow_1_1ops_1_1_top_k_1a702b5fcc223806a5b43892c840294e6e) | `::`[tensorflow::Output](/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [operation](#classtensorflow_1_1ops_1_1_top_k_1a6772614af084e9178999f8b10e356ce4) | [Operation](/versions/r2.3/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [values](#classtensorflow_1_1ops_1_1_top_k_1a3d754e075cd5e04093e27e60a6a07727) | `::`[tensorflow::Output](/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public static functions ||\n|------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|\n| [Sorted](#classtensorflow_1_1ops_1_1_top_k_1ac5e55d49539ee3457dc1a432480e85c2)`(bool x)` | [Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/top-k/attrs#structtensorflow_1_1ops_1_1_top_k_1_1_attrs) |\n\n| ### Structs ||\n|----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::TopK::Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/top-k/attrs) | Optional attribute setters for [TopK](/versions/r2.3/api_docs/cc/class/tensorflow/ops/top-k#classtensorflow_1_1ops_1_1_top_k). |\n\nPublic attributes\n-----------------\n\n### indices\n\n```text\n::tensorflow::Output indices\n``` \n\n### operation\n\n```text\nOperation operation\n``` \n\n### values\n\n```text\n::tensorflow::Output values\n``` \n\nPublic functions\n----------------\n\n### TopK\n\n```gdscript\n TopK(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n ::tensorflow::Input k\n)\n``` \n\n### TopK\n\n```gdscript\n TopK(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n ::tensorflow::Input k,\n const TopK::Attrs & attrs\n)\n``` \n\nPublic static functions\n-----------------------\n\n### Sorted\n\n```text\nAttrs Sorted(\n bool x\n)\n```"]]