""" relu ~~~~ Plots a graph of the squashing function used by a rectified linear unit.""" import numpy as np import matplotlib.pyplot as plt z = np.arange(-2, 2, .1) zero = np.zeros(len(z)) y = np.max([zero, z], axis=0) fig = plt.figure() ax = fig.add_subplot(111) ax.plot(z, y) ax.set_ylim([-2.0, 2.0]) ax.set_xlim([-2.0, 2.0]) ax.grid(True) ax.set_xlabel('z') ax.set_title('Rectified linear unit') plt.show()