We proceed with activation functions as follows:
- Threshold activation function: this is the simplest activation function. Here, the neuron fires if the activity of the neuron is greater than zero; otherwise, it does not fire. Here is the plot of the threshold activation function as the activity of the neuron changes along with the code to implement the threshold activation function in TensorFlow:
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt # Threshold Activation function def threshold (x): cond = tf.less(x, tf.zeros(tf.shape(x), dtype = x.dtype)) out = tf.where(cond, tf.zeros(tf.shape(x)), tf.ones(tf.shape(x))) return out # Plotting Threshold Activation Function h = np.linspace(-1,1,50) ...