সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
টেনসরফ্লো :: অপস:: বিটকাস্ট
#include <array_ops.h>
ডেটা অনুলিপি না করে একটি টেনসরকে এক প্রকার থেকে অন্য প্রকারে বিটকাস্ট করে।
সারাংশ
একটি টেনসর input
দেওয়া হলে, এই ক্রিয়াকলাপটি একটি টেনসর প্রদান করে যাতে ডেটাটাইপ type
input
হিসাবে একই বাফার ডেটা থাকে।
যদি ইনপুট ডেটাটাইপ T
আউটপুট ডেটাটাইপ type
চেয়ে বড় হয় তবে আকৃতি [...] থেকে [..., sizeof( T
)/sizeof( type
)] এ পরিবর্তিত হয়।
যদি T
type
থেকে ছোট হয়, তাহলে অপারেটরের ডানদিকের ডাইমেনশনটি সাইজফ( 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)
<tf.Tensor: ... shape=(4,), dtype=uint8, numpy=array([255, 255, 255, 255], dtype=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)
দ্রষ্টব্য : বিটকাস্ট একটি নিম্ন-স্তরের কাস্ট হিসাবে প্রয়োগ করা হয়েছে, তাই বিভিন্ন এন্ডিয়ান অর্ডারিং সহ মেশিনগুলি বিভিন্ন ফলাফল দেবে।
যুক্তি:
- স্কোপ: একটি স্কোপ অবজেক্ট
রিটার্ন:
পাবলিক বৈশিষ্ট্য
পাবলিক ফাংশন
নোড
::tensorflow::Node * node() const
operator::tensorflow::Input() const
অপারেটর::টেনসরফ্লো::আউটপুট
operator::tensorflow::Output() const
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-25 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-07-25 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["# tensorflow::ops::Bitcast Class Reference\n\ntensorflow::ops::Bitcast\n========================\n\n`#include \u003carray_ops.h\u003e`\n\nBitcasts a tensor from one type to another without copying data.\n\nSummary\n-------\n\nGiven a tensor `input`, this operation returns a tensor that has the same buffer data as `input` with datatype `type`.\n\nIf the input datatype `T` is larger than the output datatype `type` then the shape changes from \\[...\\] to \\[..., sizeof(`T`)/sizeof(`type`)\\].\n\nIf `T` is smaller than `type`, the operator requires that the rightmost dimension be equal to sizeof(`type`)/sizeof(`T`). The shape then goes from \\[..., sizeof(`type`)/sizeof(`T`)\\] to \\[...\\].\n\ntf.bitcast() and tf.cast() work differently when real dtype is casted as a complex dtype (e.g. tf.complex64 or tf.complex128) as tf.cast() make imaginary part 0 while tf.bitcast() gives module error. For example,\n\nExample 1: \n\n```carbon\n\u003e\u003e\u003e a = [1., 2., 3.]\n\u003e\u003e\u003e equality_bitcast = tf.bitcast(a,tf.complex128)\ntensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot bitcast from float to complex128: shape [3] [Op:Bitcast]\n\u003e\u003e\u003e equality_cast = tf.cast(a,tf.complex128)\n\u003e\u003e\u003e print(equality_cast)\ntf.Tensor([1.+0.j 2.+0.j 3.+0.j], shape=(3,), dtype=complex128)\n```\nExample 2: \n\n```gdscript\n\u003e\u003e\u003e tf.bitcast(tf.constant(0xffffffff, dtype=tf.uint32), tf.uint8)\n\u003ctf.Tensor: ... shape=(4,), dtype=uint8, numpy=array([255, 255, 255, 255], dtype=uint8)\u003e\n```\nExample 3: \n\n```carbon\n\u003e\u003e\u003e x = [1., 2., 3.]\n\u003e\u003e\u003e y = [0., 2., 3.]\n\u003e\u003e\u003e equality= tf.equal(x,y)\n\u003e\u003e\u003e equality_cast = tf.cast(equality,tf.float32)\n\u003e\u003e\u003e equality_bitcast = tf.bitcast(equality_cast,tf.uint8)\n\u003e\u003e\u003e print(equality)\ntf.Tensor([False True True], shape=(3,), dtype=bool)\n\u003e\u003e\u003e print(equality_cast)\ntf.Tensor([0. 1. 1.], shape=(3,), dtype=float32)\n\u003e\u003e\u003e print(equality_bitcast)\ntf.Tensor(\n[[ 0 0 0 0]\n [ 0 0 128 63]\n [ 0 0 128 63]], shape=(3, 4), dtype=uint8)\n```\n\n\u003cbr /\u003e\n\n*NOTE* : [Bitcast](/versions/r2.0/api_docs/cc/class/tensorflow/ops/bitcast#classtensorflow_1_1ops_1_1_bitcast) is implemented as a low-level cast, so machines with different endian orderings will give different results.\n\nArguments:\n\n- scope: A [Scope](/versions/r2.0/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.0/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): The output tensor.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [Bitcast](#classtensorflow_1_1ops_1_1_bitcast_1a05bc5afdb6742a02847bb3a8d621b149)`(const ::`[tensorflow::Scope](/versions/r2.0/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, DataType type)` ||\n\n| ### Public attributes ||\n|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_bitcast_1a73096d45a2f9d4344e1129af8152435c) | [Operation](/versions/r2.0/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_bitcast_1a4b3a50f16d6247d11bfe2d42f5a438fd) | `::`[tensorflow::Output](/versions/r2.0/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public functions ||\n|-------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_bitcast_1a999d383445adeaf4c5306b84acc32444)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_bitcast_1a26b9e16d876ed44fa37352c733696aec)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_bitcast_1ad3b38ccb536d06b4ce4f2f48af30b1f5)`() const ` | ` ` ` ` |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### output\n\n```text\n::tensorflow::Output output\n``` \n\nPublic functions\n----------------\n\n### Bitcast\n\n```gdscript\n Bitcast(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n DataType type\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n```"]]