Table Of Contents
Tinkering With Activation Functions
In [5]:
import tensorflow as tf
import matplotlib.pyplot as pltCreate Some Mock Data
In [4]:
dataMin = -10
dataMax = 10
rangeTensor = tf.range(dataMin, dataMax)
mockData = tf.cast(dataRange, tf.float32)
mockDataOut [4]:
In [7]:
# Visualize the data
plt.plot(mockData);A Sigmoid Function
In [10]:
# Sigmoid - https://www.tensorflow.org/api_docs/python/tf/keras/activations/sigmoid
def mySigmoid(x):
return 1 / (1 + tf.exp(-x))
# Use the sigmoid function on our tensor
sigmoidData = mySigmoid(mockData)
sigmoidDataOut [10]:
In [11]:
plt.plot(sigmoidData);A Relu Function
In [14]:
# ReLU - https://www.tensorflow.org/api_docs/python/tf/keras/activations/relu
def myRelu(x):
return tf.maximum(0, x)
reluData = myRelu(mockData)
reluDataOut [14]:
In [15]:
plt.plot(reluData)Out [15]: