tensorflow :: ops :: 비트 캐스트

#include <array_ops.h>

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

요약

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

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

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

tf.cast ()가 가상 부분을 0으로 만들고 tf.bitcast ()가 모듈을 제공하므로 실제 dtype이 복잡한 dtype (예 : tf.complex64 또는 tf.complex128)으로 캐스팅 될 때 tf.bitcast () 및 tf.cast ()가 다르게 작동합니다. 오류. 예를 들면

예 1 :

a = [1., 2., 3.] equality_bitcast = tf.bitcast (a, tf.complex128) 역 추적 (최근 최근 호출) : ... InvalidArgumentError : 1에서 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 0128 63] [0 0128 63]], shape = (3, 4), dtype = uint8)

참고 : 비트 캐스트는 저수준 캐스트로 구현되므로 엔디안 순서가 다른 시스템은 다른 결과를 제공합니다.

인수 :

보고:

생성자와 소멸자

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 

연산자 :: tensorflow :: 입력

 operator::tensorflow::Input() const 

연산자 :: tensorflow :: 출력

 operator::tensorflow::Output() const