tensorflow:: عملیات:: وان‌هات

#include <array_ops.h>

یک تانسور تک‌داغ (one-hot) برمی‌گرداند.

خلاصه

مکان‌هایی که توسط اندیس‌ها در 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)

ساختارها

tensorflow:: عملیات:: OneHot:: جذابیت‌ها

تنظیم‌کننده‌های ویژگی اختیاری برای 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
)