텐서플로우:: 연산:: 비트캐스트

#include <array_ops.h>

데이터를 복사하지 않고 텐서를 한 유형에서 다른 유형으로 비트캐스팅합니다.

요약

텐서 input 주어지면, 이 연산은 input 과 동일한 버퍼 데이터를 가지면서 데이터 형식은 type 인 텐서를 반환합니다.

입력 데이터 유형 T 출력 데이터 유형 type 보다 크면 모양이 [...]에서 [..., sizeof( T )/sizeof( type )]으로 변경됩니다.

T 가 type 보다 작으면 연산자는 가장 오른쪽 차원이 sizeof( type )/sizeof( T )와 같아야 한다고 요구합니다. 그러면 모양은 [..., sizeof( type )/sizeof( T )]에서 [...]로 바뀝니다.

실수 데이터 타입을 복소수 데이터 타입(예: tf.complex64 또는 tf.complex128)으로 캐스팅할 때 tf.bitcast()와 tf.cast()는 다르게 작동합니다. tf.cast()는 허수 부분을 0으로 만드는 반면, tf.bitcast()는 모듈 오류를 발생시킵니다. 예를 들어,

예시 1:

a = [1., 2., 3.] equality_bitcast = tf.bitcast(a, tf.complex128) Traceback (most recent call last): ... InvalidArgumentError: Cannot bitcast from 1 to 18 [Op: Bitcast ] equality_cast = tf.cast(a, tf.complex128) print(equality_cast) tf.Tensor([1.+0.j 2.+0.j 3.+0.j], shape=(3,), dtype=complex128)

예시 2:

tf.bitcast(tf.constant(0xffffffff, dtype=tf.uint32), tf.uint8)

예시 3:

x = [1., 2., 3.] y = [0., 2., 3.] equality = tf.equal(x, y) equality_cast = tf.cast(equality, tf.float32) equality_bitcast = tf.bitcast(equality_cast, tf.uint8) print(equality) tf.Tensor([False True True], shape=(3,), dtype=bool) print(equality_cast) tf.Tensor([0. 1. 1.], shape=(3,), dtype=float32) print(equality_bitcast) tf.Tensor( [[ 0 0 0 0] [ 0 0 128 63] [ 0 0 128 63]], shape=(3, 4), dtype=uint8)

참고 : Bitcast 는 저수준 형변환으로 구현되어 있으므로 엔디안 순서가 다른 컴퓨터에서는 결과가 다르게 나타날 수 있습니다.

논거:

보고:

생성자와 소멸자

Bitcast (const :: tensorflow::Scope & scope, :: tensorflow::Input input, DataType type)

공개 속성

operation
output

공공 기능

node () const
::tensorflow::Node *
operator::tensorflow::Input () const
operator::tensorflow::Output () const

공개 속성

작업

Operation operation

산출

::tensorflow::Output output

공공 기능

비트캐스트

 Bitcast(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  DataType type
)

마디

::tensorflow::Node * node() const 

연산자::텐서플로우::입력

 operator::tensorflow::Input() const 

연산자::텐서플로우::출력

 operator::tensorflow::Output() const