텐서플로우:: 작전:: 비트캐스트

#include <array_ops.h>

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

요약

텐서 input 주어지면 이 작업은 데이터 유형 typeinput 과 동일한 버퍼 데이터를 갖는 텐서를 반환합니다.

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

Ttype 보다 작은 경우 연산자는 가장 오른쪽 차원이 sizeof( type )/sizeof( T )와 같아야 합니다. 그런 다음 모양은 [..., sizeof( type )/sizeof( T )]에서 [...]로 변경됩니다.

tf.bitcast() 및 tf.cast()는 실제 dtype이 복합 dtype(예: tf.complex64 또는 tf.complex128)으로 캐스팅될 때 다르게 작동합니다. tf.cast()는 허수 부분을 0으로 만들고 tf.bitcast()는 모듈을 제공하기 때문입니다. 오류. 예를 들어,

예 1:

>>> a = [1., 2., 3.]
>>> equality_bitcast = tf.bitcast(a,tf.complex128)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot bitcast from float to complex128: shape [3] [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