tensorflow:: אופס:: TopK
#include <nn_ops.h>
מוצא ערכים ואינדקסים של k
האלמנטים הגדולים ביותר עבור הממד האחרון.
תַקצִיר
אם הקלט הוא וקטור (דרגה-1), מוצא את k
הערכים הגדולים בוקטור ומוציא את הערכים והמדדים שלהם כווקטורים. לפיכך, values[j]
הוא הערך j
בגודלו input
, והאינדקס שלו הוא indices[j]
.
עבור מטריצות (בהתאמה קלט בדרגה גבוהה יותר), מחשב את k
הערכים העליונים בכל שורה (לפי וקטור לאורך הממד האחרון). כָּך,
values.shape = indices.shape = input.shape[:-1] + [k]
אם שני אלמנטים שווים, אלמנט האינדקס התחתון מופיע ראשון.
טיעונים:
- scope: אובייקט Scope
- קלט: 1-D ומעלה עם ממד אחרון לפחות
k
. - k: 0-D. מספר האלמנטים העליונים שיש לחפש לאורך הממד האחרון (לאורך כל שורה עבור מטריצות).
מאפיינים אופציונליים (ראה Attrs
):
- sorted: אם נכון, ה-
k
האלמנטים שיתקבלו ימוינו לפי הערכים בסדר יורד.
החזרות:
- ערכי
Output
: k
האלמנטים הגדולים ביותר לאורך כל פרוסה ממדית אחרונה. - מדדי
Output
: המדדים של values
בתוך הממד האחרון של input
.
פונקציות סטטיות ציבוריות |
---|
Sorted (bool x) | |
תכונות ציבוריות
מדדים
::tensorflow::Output indices
מִבצָע
Operation operation
ערכים
::tensorflow::Output values
תפקידים ציבוריים
TopK
TopK(
const ::tensorflow::Scope & scope,
::tensorflow::Input input,
::tensorflow::Input k
)
TopK
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 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-27 (שעון UTC)."],[],[],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```"]]