Python | tensorflow.bitcast() method Last Updated : 23 Feb, 2023 Comments Improve Suggest changes Like Article Like Report TensorFlow is open-source python library designed by Google to develop Machine Learning models and deep learning neural networks. bitcast() is method in tensorflow library which is used to bitcast a tensor from one type to another type. It doesn't copy the data. Syntax: tf.bitcast( input, type, name ) Arguments: 1. input: It is the Tensor and the allowed type for this tensor are bfloat16, half, float32, float64, int64, int32, uint8, uint16, uint32, uint64, int8, int16, complex64, complex128, qint8, quint8, qint16, quint16, qint32. 2. type: It defines the dtype in which input need to be bitcasted. 3. name: It is an optional argument. It is used to give a name to operation. Return: It returns a tensor of type type. Note: bitcast can't be used to cast real dtype to complex dtype. It will raise InvalidArgumentError. Example 1: Python3 # importing the library import tensorflow # initializing the constant tensor of dtype uint32 a = tensorflow.constant(0xffffffff, dtype=tensorflow.uint32) # Checking the initialized tensor print('a:',a) # bitcasting to dtype uint8 b = tensorflow.bitcast(a, tensorflow.uint8) # Checking the bitcasted tensor print('b:',b) Output: a: tf.Tensor(4294967295, shape=(), dtype=uint32) b: tf.Tensor([255 255 255 255], shape=(4,), dtype=uint8) Example 2: This example tries to bitcast a real dtype to complex dtype Python3 # importing the library import tensorflow # initializing the constant tensor of dtype uint32 a = tensorflow.constant(0xffffffff, dtype=tensorflow.uint32) # Checking the initialized tensor print('a:',a) # bitcasting to dtype complex128 b = tensorflow.bitcast(a, tensorflow.complex128) Output: Comment More infoAdvertise with us Next Article Python | tensorflow.bitcast() method aman neekhara Follow Improve Article Tags : Python Python-Tensorflow Practice Tags : python Similar Reads Python - Tensorflow bitwise.invert() method Tensorflow bitwise.invert() method performs the invert operation and the result will invert the bits, Like 0 to 1 and 1 to 0. The operation is done on the representation of a. This method belongs to bitwise module. Syntax: tf.bitwise.invert( a, name=None) Arguments a: This must be a Tensor.It should 2 min read Python - tensorflow.boolean_mask() method TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. boolean_mask() is method used to apply boolean mask to a Tensor. Syntax: tensorflow.boolean_mask(tensor, mask, axis, name) Parameters: tensor: It's a N-dimensional input 2 min read Python - Tensorflow bitwise.bitwise_or() method Tensorflow bitwise.bitwise_or() method performs the bitwise_or operation and return those bits set, that are either set(1) in a or in b or in both. The operation is done on the representation of a and b. This method belongs to bitwise module. Syntax: tf.bitwise.bitwise_or( a, b, name=None) Arguments 2 min read Python - Tensorflow bitwise.left_shift() method Tensorflow bitwise.left_shift() method performs the left_shift operation on input a defined by input b and return the new constant. The operation is done on the representation of a and b. This method belongs to bitwise module. Syntax: tf.bitwise.left_shift( a, b, name=None) Arguments a: This must be 2 min read Tensorflow bitwise.bitwise_xor() method - Python Tensorflow bitwise.bitwise_xor() method performs the bitwise_xor operation and the result will set those bits, that are different in a and b. The operation is done on the representation of a and b. This method belongs to bitwise module. Syntax: tf.bitwise.bitwise_xor(a, b, name=None) Arguments a: Th 2 min read Python - Tensorflow bitwise.bitwise_and() method Tensorflow bitwise.bitwise_and() method performs the bitwise_and operation and return those bits set, that are set(1) in both a and b. The operation is done on the representation of a and b. This method belongs to bitwise module. Syntax: tf.bitwise.bitwise_and( a, b, name=None) Arguments a: This mus 2 min read Python - Tensorflow bitwise.right_shift() method Tensorflow bitwise.right_shift() method performs the right_shift operation on input a defined by input b and return the new constant. The operation is done on the representation of a and b. This method belongs to bitwise module. Syntax: tf.bitwise.right_shift( a, b, name=None) Arguments a: This must 2 min read Python - tensorflow.gather() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. gather() is used to slice the input tensor based on the indices provided. Syntax: tensorflow.gather( params, indices, validate_indices, axis, batch_dims, name) Paramete 2 min read Python - tensorflow.gather_nd() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. gather_nd() is used to gather the slice from input tensor based on the indices provided. Syntax: tensorflow.gather_nd( params, indices, batch_dims, name) Parameters: pa 2 min read Python - tensorflow.identity_n() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. identity_n() is used get a list of Tensor with same shape and content as input Tensor. Syntax: tensorflow.identity_n( input, name) Parameters: input:  It is a Tensor.na 2 min read Like