Python - tensorflow.math.sign() Last Updated : 05 Nov, 2021 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. sign() is used to find element wise indication of the sign of a number. Specifically, y = sign(x) = -1 if x < 0; 0 if x == 0; 1 if x > 0. For complex numbers, y = sign(x) = x / |x| if x != 0, otherwise y = 0. Syntax: tensorflow.math.sign(x, name) Parameters: x: It's a tensor. Allowed dtypes are bfloat16, half, float32, float64, int32, int64, complex64, complex128.name(optional): It defines the name for the operation. Return: It return a tensor of same dtype as x. Example 1: Python3 # importing the library import tensorflow as tf # Initializing the input tensor a = tf.constant([0, 1, -2, 3, -4], dtype = tf.float64) # Printing the input tensor print('a: ', a) # Calculating result res = tf.math.sign(x = a) # Printing the result print('Result: ', res) Output: a: tf.Tensor([ 0. 1. -2. 3. -4.], shape=(5, ), dtype=float64) Result: tf.Tensor([ 0. 1. -1. 1. -1.], shape=(5, ), dtype=float64) Example 2: Python3 # importing the library import tensorflow as tf # Initializing the input tensor a = tf.constant([ 1-5j, -2 + 3j, -3-7j, -4 + 8j], dtype = tf.complex128) # Printing the input tensor print('a: ', a) # Calculating result res = tf.math.sign(x = a) # Printing the result print('Result: ', res) Output: a: tf.Tensor([ 1.-5.j -2.+3.j -3.-7.j -4.+8.j], shape=(4, ), dtype=complex128) Result: tf.Tensor( [ 0.19611614-0.98058068j -0.5547002 +0.83205029j -0.3939193 -0.91914503j -0.4472136 +0.89442719j], shape=(4, ), dtype=complex128) Comment More infoAdvertise with us Next Article Python - tensorflow.math.sign() A aman neekhara Follow Improve Article Tags : Machine Learning AI-ML-DS With Python Practice Tags : Machine Learning Similar Reads Python - tensorflow.math.rint() TensorFlow is open-source python library designed by Google to develop Machine Learning models and deep learning  neural networks. rint() is used to find element-wise integer closest to x. Syntax: tf.math.rint(x, name) Parameter: x: It's the input tensor. Allowed dtype for this tensor are bfloat16, 2 min read Python - tensorflow.math.sigmoid() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning neural networks. sigmoid() is used to find element wise sigmoid of x. Syntax: tensorflow.math.sigmoid(x, name) Parameters: x: It's a tensor. Allowed dtypes are float16, float32, float64, 1 min read Python - tensorflow.math.real() TensorFlow is open-source python library designed by Google to develop Machine Learning models and deep learning  neural networks. real() is used to find element wise real part of a tensor. Syntax: tf.math.real(x, name) Parameter: x: It's the input tensor. Allowed dtype for this tensor are bfloat16, 2 min read Python - tensorflow.math.log_sigmoid() TensorFlow is open-source python library designed by Google to develop Machine Learning models and deep learning  neural networks. log_sigmoid() is used to find element wise log sigmoid of x. Specifically, y = log(1 / (1 + exp(-x))). Syntax: tf.math.log_sigmoid(x, name) Parameter: x: It's the input 1 min read Python - tensorflow.math.pow() TensorFlow is open-source python library designed by Google to develop Machine Learning models and deep learning  neural networks. pow() is used to find element wise x^y. Syntax: tf.math.pow(x, y, name) Parameter: x: It's the input tensor. Allowed dtype for this tensor are float16, float32, float64, 2 min read Like