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 be a Tensor. It should be from the one of the following types: int8, int16, int32, int64, uint8, uint16, uint32, uint64.
- b: This should also be a Tensor, Type same as a.
- name: This is optional parameter and this is the name of the operation.
Return: It returns a Tensor having the same type as a and b.
Let’s see this concept with the help of few examples:
Example 1:
Example 1:
# Importing the Tensorflow library import tensorflow as tf # A constant a and b a = tf.constant(256, dtype = tf.int32) b = tf.constant(1, dtype = tf.int32) # Applying the right_shift() function # storing the result in 'c' c = tf.bitwise.right_shift(a, b) # Initiating a Tensorflow session with tf.Session() as sess: print("Input 1", a) print(sess.run(a)) print("Input 2", b) print(sess.run(b)) print("Output: ", c) print(sess.run(c)) |
Output:
Input 1 Tensor("Const_57:0", shape=(), dtype=int32)
256
Input 2 Tensor("Const_58:0", shape=(), dtype=int32)
1
Output: Tensor("RightShift_3:0", shape=(), dtype=int32)
128
Example 2:
# Importing the Tensorflow library import tensorflow as tf # A constant a and b a = tf.constant([8, 16, 32], dtype = tf.int32) b = tf.constant([2, 2, 3], dtype = tf.int32) # Applying the right_shift() function # storing the result in 'c' c = tf.bitwise.right_shift(a, b) # Initiating a Tensorflow session with tf.Session() as sess: print("Input 1", a) print(sess.run(a)) print("Input 2", b) print(sess.run(b)) print("Output: ", c) print(sess.run(c)) |
Output:
Input 1 Tensor("Const_53:0", shape=(3, ), dtype=int32)
[ 8 16 32]
Input 2 Tensor("Const_54:0", shape=(3, ), dtype=int32)
[2 2 3]
Output: Tensor("RightShift_1:0", shape=(3, ), dtype=int32)
[2 4 4]
<!–
–>

numpy.right_shift() in Python

Tensorflow bitwise.bitwise_xor() method – Python

Python – Tensorflow bitwise.left_shift() method

Python – Tensorflow bitwise.bitwise_and() method

Python – Tensorflow bitwise.invert() method

Python – Tensorflow bitwise.bitwise_or() method

Why TensorFlow is So Popular – Tensorflow Features

Python | Tensorflow cos() method

Python | Tensorflow sin() method

Python | Tensorflow atan() method




Please Login to comment…