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 )] থেকে [...]-এ পরিবর্তিত হয়।

যখন কোনো রিয়েল ডেটাটাইপকে (dtype) একটি কমপ্লেক্স ডেটাটাইপে (যেমন tf.complex64 বা tf.complex128) কাস্ট করা হয়, তখন tf.bitcast() এবং tf.cast() ভিন্নভাবে কাজ করে, কারণ tf.cast() ইমাজিনারি পার্টকে (imaginary part) ০ করে দেয়, অন্যদিকে tf.bitcast() মডিউল এরর (module error) দেয়। উদাহরণস্বরূপ,

উদাহরণ ১:

a = [1., 2., 3.] equality_bitcast = tf.bitcast(a, tf.complex128) ট্রেসব্যাক (সর্বশেষ কল): ... InvalidArgumentError: 1 থেকে 18 পর্যন্ত বিটকাস্ট করা যাবে না [অপারেশন: 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)

উদাহরণ ৩:

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)

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

যুক্তি:

ফেরত:

  • 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