جریان تنسور:: عملیات:: 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)

صفات عمومی

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

 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
)