tensorflow:: ops:: OneHot
#include <array_ops.h>מחזירה טנזור בעל ערך חם אחד.
תַקצִיר
המיקומים המיוצגים על ידי אינדקסים בתוך indices מקבלים ערך on_value , בעוד שכל שאר המיקומים מקבלים ערך off_value .
אם indices הקלט הם דרגה N , לפלט תהיה דרגה N+1 . הציר החדש נוצר axis הממדים (ברירת מחדל: הציר החדש יתווסף בסוף).
אם indices הם סקלריים, צורת הפלט תהיה וקטור בעל אורך depth .
אם indices הם וקטור של features אורך, צורת הפלט תהיה:
features x depth if axis == -1 depth x features if axis == 0
אם indices הוא מטריצה (batch) עם צורה [batch, features] , צורת הפלט תהיה:
batch x features x depth if axis == -1 batch x depth x features if axis == 1 depth x batch x features if axis == 0
דוגמאות
נניח ש
indices = [0, 2, -1, 1] depth = 3 on_value = 5.0 off_value = 0.0 axis = -1
אז הפלט הוא [4 x 3] :
output = [5.0 0.0 0.0] // one_hot(0) [0.0 0.0 5.0] // one_hot(2) [0.0 0.0 0.0] // one_hot(-1) [0.0 5.0 0.0] // one_hot(1)
נניח ש
indices = [0, 2, -1, 1] depth = 3 on_value = 0.0 off_value = 3.0 axis = 0
אז הפלט הוא [3 x 4] :
output = [0.0 3.0 3.0 3.0] [3.0 3.0 3.0 0.0] [3.0 3.0 3.0 3.0] [3.0 0.0 3.0 3.0] // ^ one_hot(0) // ^ one_hot(2) // ^ one_hot(-1) // ^ one_hot(1)
נניח ש
indices = [[0, 2], [1, -1]] depth = 3 on_value = 1.0 off_value = 0.0 axis = -1
אז הפלט הוא [2 x 2 x 3] :
output =
[
[1.0, 0.0, 0.0] // one_hot(0)
[0.0, 0.0, 1.0] // one_hot(2)
][
[0.0, 1.0, 0.0] // one_hot(1)
[0.0, 0.0, 0.0] // one_hot(-1)
]טיעונים:
- היקף: אובייקט היקף
- אינדקסים: טנזור של אינדקסים.
- עומק: סקלר המגדיר את העומק של המימד החם האחד.
- on_value: סקלר המגדיר את הערך שיש למלא בפלט כאשר
indices[j] = i. - off_value: סקלר המגדיר את הערך שיש למלא בפלט כאשר
indices[j] != i.
מאפיינים אופציונליים (ראה Attrs ):
- ציר: הציר למילוי (ברירת מחדל: -1, ציר פנימי חדש).
החזרות:
-
Output: הטנזור החד-חם.
בנאים והורסים | |
|---|---|
OneHot (const :: tensorflow::Scope & scope, :: tensorflow::Input indices, :: tensorflow::Input depth, :: tensorflow::Input on_value, :: tensorflow::Input off_value) | |
OneHot (const :: tensorflow::Scope & scope, :: tensorflow::Input indices, :: tensorflow::Input depth, :: tensorflow::Input on_value, :: tensorflow::Input off_value, const OneHot::Attrs & attrs) |
מאפיינים ציבוריים | |
|---|---|
operation | |
output | |
תפקידים ציבוריים | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
פונקציות סטטיות ציבוריות | |
|---|---|
Axis (int64 x) | |
מבנים | |
|---|---|
| tensorflow:: ops:: OneHot:: Attrs | קובעי מאפיינים אופציונליים עבור OneHot . |
מאפיינים ציבוריים
מִבצָע
Operation operation
תְפוּקָה
::tensorflow::Output output
תפקידים ציבוריים
וואן הוט
OneHot( const ::tensorflow::Scope & scope, ::tensorflow::Input indices, ::tensorflow::Input depth, ::tensorflow::Input on_value, ::tensorflow::Input off_value )
וואן הוט
OneHot( const ::tensorflow::Scope & scope, ::tensorflow::Input indices, ::tensorflow::Input depth, ::tensorflow::Input on_value, ::tensorflow::Input off_value, const OneHot::Attrs & attrs )
צוֹמֶת
::tensorflow::Node * node() const
אופרטור::tensorflow::קלט
operator::tensorflow::Input() const
אופרטור::tensorflow::פלט
operator::tensorflow::Output() const
פונקציות סטטיות ציבוריות
צִיר
Attrs Axis( int64 x )
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2026-11-05 (שעון UTC).