tensorflow:: אופס:: 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 מיושם כקאסט ברמה נמוכה, כך שמכונות עם סדרי אנדיאנים שונים יתנו תוצאות שונות.

טיעונים:

  • scope: אובייקט Scope

החזרות:

  • 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