tensorflow:: אופס:: 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, 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) ]
טיעונים:
- scope: אובייקט Scope
- מדדים: טנסור של מדדים.
- עומק: סקלאר המגדיר את עומק המימד החם האחד.
- 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) |
תפקידים ציבוריים | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
מבנים | |
---|---|
tensorflow:: ops:: OneHot:: Attrs | קובעי תכונות אופציונליים עבור OneHot . |
תכונות ציבוריות
מִבצָע
Operation operation
תְפוּקָה
::tensorflow::Output output
תפקידים ציבוריים
OneHot
OneHot( const ::tensorflow::Scope & scope, ::tensorflow::Input indices, ::tensorflow::Input depth, ::tensorflow::Input on_value, ::tensorflow::Input off_value )
OneHot
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 )