از اینکه با Google I/O تنظیم کردید متشکریم. مشاهده همه جلسات در صورت تقاضا تماشا کنید

tensorflow :: ops :: Bitcast

#include <array_ops.h>

بدون کپی کردن داده ها ، یک سنسور را از یک نوع به نوع دیگر ارسال می کند.

خلاصه

با توجه به input تنسور ، این عملیات یک سنسور را برمی گرداند که دارای داده بافر یکسانی با input با نوع داده type .

اگر نوع داده ورودی T بزرگتر از خروجی نوع داده است type سپس تغییرات شکل از [...] به [...، SIZEOF ( T ) / SIZEOF ( type )].

اگر T کوچکتر از type ، اپراتور نیاز دارد که درست ترین اندازه برابر با 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 به عنوان بازیگران سطح پایین اجرا می شود ، بنابراین ماشین آلات با ترتیب مختلف endian نتایج متفاوتی می دهند.

استدلال ها:

بازده:

  • Output : تانسور خروجی.

سازندگان و ویرانگران

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

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

گره

::tensorflow::Node * node() const 

عملگر :: tensorflow :: ورودی

 operator::tensorflow::Input() const 

عملگر :: tensorflow :: خروجی

 operator::tensorflow::Output() const