Skip to content

Commit 092007f

Browse files
Chapter 4 - vanishing gradient problem in a deep networks
1 parent 7283525 commit 092007f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

test.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
22
Testing code for different neural network configurations.
3-
Adapted for Python 3.4.3
3+
Adapted for Python 3.5.2
44
55
Usage in shell:
6-
python3 test.py
6+
python3.5 test.py
77
88
Network (network.py and network2.py) parameters:
99
2nd param is epochs count
@@ -64,12 +64,6 @@
6464
monitor_training_accuracy=True)
6565
'''
6666

67-
net = network2.Network([784, 30, 10], cost=network2.CrossEntropyCost)
68-
net.SGD(training_data[:1000], 30, 10, 0.5,
69-
lmbda=5.0,
70-
evaluation_data=validation_data,
71-
monitor_evaluation_accuracy=True)
72-
7367
# chapter 3 - Early stopping implemented
7468
'''
7569
net = network2.Network([784, 30, 10], cost=network2.CrossEntropyCost)
@@ -81,6 +75,16 @@
8175
early_stopping_n=10)
8276
'''
8377

78+
# chapter 4 - The vanishing gradient problem - deep networks are hard to train with simple SGD algorithm
79+
# this network learns much slower than a shallow one.
80+
net = network2.Network([784, 30, 30, 30, 30, 10], cost=network2.CrossEntropyCost)
81+
net.SGD(training_data, 30, 10, 0.1,
82+
lmbda=5.0,
83+
evaluation_data=validation_data,
84+
monitor_evaluation_accuracy=True)
85+
86+
87+
8488
# ----------------------
8589
# - network3.py example:
8690
import network3

0 commit comments

Comments
 (0)