텐서플로우:: ops:: 원핫

#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 객체
  • 인덱스: 인덱스 텐서입니다.
  • depth: 원핫 차원의 깊이를 정의하는 스칼라 값입니다.
  • on_value: indices[j] = i 일 때 출력에 채울 값을 정의하는 스칼라입니다.
  • off_value: indices[j] != i 일 때 출력을 채울 값을 정의하는 스칼라입니다.

선택적 속성( Attrs 참조):

  • 축: 채울 축(기본값: -1, 가장 안쪽의 새 축).

보고:

생성자와 소멸자

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)

구조

텐서플로우:: 연산:: 원핫:: 속성

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
)