Skip to content

Commit bcfcf75

Browse files
committed
Added graph for rectified linear unit
1 parent 8d28a94 commit bcfcf75

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

fig/chap3/relu.png

25.3 KB
Loading

fig/chap3/relu.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
relu
3+
~~~~
4+
5+
Plots a graph of the squashing function used by a rectified linear
6+
unit."""
7+
8+
import numpy as np
9+
import matplotlib.pyplot as plt
10+
11+
z = np.arange(-2, 2, .1)
12+
zero = np.zeros(len(z))
13+
y = np.max([zero, z], axis=0)
14+
15+
fig = plt.figure()
16+
ax = fig.add_subplot(111)
17+
ax.plot(z, y)
18+
ax.set_ylim([-2.0, 2.0])
19+
ax.set_xlim([-2.0, 2.0])
20+
ax.grid(True)
21+
ax.set_xlabel('z')
22+
ax.set_title('Rectified linear unit')
23+
24+
plt.show()

0 commit comments

Comments
 (0)