เทนเซอร์โฟลว์:: ปฏิบัติการ:: หนึ่งร้อน
#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)
]ข้อโต้แย้ง:
- ขอบเขต: วัตถุ ขอบเขต
- ดัชนี: เทนเซอร์ของดัชนี
- ความลึก: สเกลาร์ที่กำหนดความลึกของมิติร้อนหนึ่งมิติ
- 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) | |
โครงสร้าง | |
|---|---|
| เทนเซอร์โฟลว์ :: 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 )