tensorflow.math module provides support for many basic mathematical operations. The
tf.abs () [alias
tf.math.abs ] function provides support for absolute functions in Tensorflow. Expected to be input as complex numbers in the form or floating point. Input type — tensor, and if the input contains more than one element, the element-wise absolute value is calculated.
For a complex number the absolute value is calculated as ,
For floating point numbers the absolute value is calculated as
Syntax : tf.abs ( x, name = None) or tf.math.abs (x, name = None)
x : A Tensor or SparseTensor of type float16, float32, float64, int32, int64, complex64 or complex128.
name (optional): The name for the operation.
Return type : A Tensor or SparseTensor with the same size and type as that of x with absolute values. For complex64 or complex128 input, the returned Tensor will be of type float32 or float64, respectively.
Code # 1: For Floats
Input type: Tensor ( "Const: 0", shape = (5,), dtype = float32) Input: [-0.5 -0.1 0. 0.1 0.5] Return Type: Tensor ("abs: 0", shape = (5,), dtype = float32 ) Output: [0.5 0.1 0. 0.1 0.5]
Code # 2: Rendering
Input: [-5. -four. -3. -2. -one. 0. 1. 2. 3. 4. 5.] Output: [5. 4. 3. 2. 1. 0. 1. 2. 3. 4. 5.]
Code # 3: for complex numbers
Output: p >
Input type: Tensor ("Const_1: 0", shape = (2, 1), dtype = complex64) Input: [[-2.25 + 4.75j] [-3.25 + 5.75j]] Return Type: Tensor ( "abs_1: 0", shape = (2, 1), dtype = float32) Output: [[5.255949] [6.6049223]]
Python for Programmers: with Big Data and Artificial Intelligence Case Studies This book, written for programmers with a high-level experience in another language, uses how-to instructions to teach...
In the summer of 2008, after three decades of building software in corporate data centers, I walked away from corporate America to take a stab at building a technology company from the ground up based...
This first edition of Strategic Engineering for Cloud Computing and Big Data Analytics focuses on addressing numerous and complex, inter-related issues which are inherently linked to systems engineeri...
Computer languages have so far been of the ‘interpreted’ or the ‘compiled’ type. Compiled languages (like ‘C’) have been more common. You prepare a program, save it (the debugged version),...