How to do it...

We proceed with activation functions as follows:

  1. 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) ...

Get TensorFlow 1.x Deep Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.