تدفق التوتر:: العمليات:: البث الثنائي
#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)
>>> tf.bitcast(tf.constant(0xffffffff, dtype=tf.uint32), tf.uint8) <tf.Tensor: ... shape=(4,), dtype=uint8, numpy=array([255, 255, 255, 255], dtype=uint8)>
>>> 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 كإرسال منخفض المستوى، لذا فإن الأجهزة ذات الترتيب النهائي المختلف ستعطي نتائج مختلفة.
الحجج:
- النطاق: كائن النطاق
العوائد:
-
Output
: موتر الإخراج.
البنائين والمدمرين | |
---|---|
Bitcast (const :: tensorflow::Scope & scope, :: tensorflow::Input input, DataType type) |
الوظائف العامة | |
---|---|
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