Google I/O-তে টিউন করার জন্য ধন্যবাদ। চাহিদা অনুযায়ী সব সেশন দেখুন চাহিদা অনুযায়ী দেখুন

সেন্সরফ্লো :: অপস :: বিটকাস্ট

#include <array_ops.h>

ডেটা অনুলিপি না করে এক ধরণের থেকে অন্য ধরণের টেনসর বিটকাস্ট করুন।

সারসংক্ষেপ

একটি সেন্সর input , এই অপারেশনটি একটি টেনসর দেয় যা ডেটাটাইপ type সাথে input হিসাবে একই বাফার ডেটা রয়েছে।

যদি ইনপুট ডেটাটাইপ T আউটপুট ডেটাটাইপ type চেয়ে বড় হয় তবে আকৃতিটি [...] থেকে [..., আকারে ( T ) / আকারের ( type )] তে পরিবর্তিত হয়।

যদি T type চেয়ে ছোট হয় তবে অপারেটরের প্রয়োজন যে ডান দিকের মাত্রা মাপের ( type ) / আকারের ( T ) এর সমান। আকারটি তখন [..., আকারের ( type ) / আকারের ( 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)

দ্রষ্টব্য : বিটকাস্টটি নিম্ন-স্তরের as ালাই হিসাবে প্রয়োগ করা হয়েছে, সুতরাং বিভিন্ন এন্ডিয়ান অর্ডার সহ মেশিনগুলি বিভিন্ন ফলাফল দেয়।

যুক্তি:

রিটার্নস:

  • 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(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  DataType type
)

নোড

::tensorflow::Node * node() const 

অপারেটর :: টেনসরফ্লো :: ইনপুট

 operator::tensorflow::Input() const 

অপারেটর :: টেনসরফ্লো :: আউটপুট

 operator::tensorflow::Output() const