เทนเซอร์โฟลว์::ออปส์::วันฮอต

#include <array_ops.h>

ส่งคืนเทนเซอร์แบบวันฮอต (one-hot tensor)

สรุป

ตำแหน่งที่แสดงด้วยดัชนีใน 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 : เทนเซอร์แบบวันฮอต (one-hot tensor)

ตัวสร้างและตัวทำลาย

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 

ตัวดำเนินการ::เทนเซอร์โฟลว์::อินพุต

 operator::tensorflow::Input() const 

ตัวดำเนินการ::เทนเซอร์โฟลว์::เอาต์พุต

 operator::tensorflow::Output() const 

ฟังก์ชันคงที่สาธารณะ

แกน

Attrs Axis(
  int64 x
)