Python – tensorflow.math.sigmoid()
Last Updated :
05 Nov, 2021
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, complex64, or complex128.
- name(optional): It defines the name for the operation.
Return: It return a tensor of same dtype as x.
Example 1:
Python3
import tensorflow as tf
a = tf.constant([. 2 , . 5 , . 7 , 1 , 2 , 5 , 10 ], dtype = tf.float64)
print ( 'a: ' , a)
res = tf.math.sigmoid(x = a)
print ( 'Result: ' , res)
|
Output:
a: tf.Tensor([ 0.2 0.5 0.7 1. 2. 5. 10. ], shape=(7, ), dtype=float64)
Result: tf.Tensor(
[0.549834 0.62245933 0.66818777 0.73105858 0.88079708 0.99330715
0.9999546 ], shape=(7, ), dtype=float64)
Example 2: Visualization
Python3
import tensorflow as tf
import matplotlib.pyplot as plt
a = tf.constant([. 2 , . 5 , . 7 , 1 , 2 , 5 , 10 ], dtype = tf.float64)
res = tf.math.sigmoid(x = a)
plt.plot(a, res, color = 'green' )
plt.title( 'tensorflow.math.sigmiod' )
plt.xlabel( 'Input' )
plt.ylabel( 'Result' )
plt.show()
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...