TIPE-OperationValkyrie-Absobel/fig/replaced_by_d3/relu.py

25 lines
440 B
Python
Raw Normal View History

2021-05-30 21:31:10 +02:00
"""
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()