تدفق التوتر:: العمليات:: 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)
  ]

الحجج:

  • النطاق: كائن النطاق
  • المؤشرات: موتر المؤشرات.
  • العمق: عددي يحدد عمق البعد الساخن الواحد.
  • on_value: عددي يحدد القيمة المراد ملؤها في المخرجات عندما تكون indices[j] = i .
  • off_value: عددي يحدد القيمة المراد ملؤها في المخرجات عندما indices[j] != i .

السمات الاختيارية (انظر Attrs ):

  • axis: المحور المطلوب ملؤه (الافتراضي: -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
)