Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joyhuang9473/3fc1b204488622e9c307 to your computer and use it in GitHub Desktop.
Save joyhuang9473/3fc1b204488622e9c307 to your computer and use it in GitHub Desktop.
generate some 'random' test data and test (input_layer_size = 3; hidden_layer_size = 5; num_labels = 3; m = 5;)
% Octave console output
Initializing Neural Network Parameters ...
Checking Backpropagation...
-9.2783e-03 -9.2783e-03
8.8991e-03 8.8991e-03
-8.3601e-03 -8.3601e-03
7.6281e-03 7.6281e-03
-6.7480e-03 -6.7480e-03
-3.0498e-06 -3.0498e-06
1.4287e-05 1.4287e-05
-2.5938e-05 -2.5938e-05
3.6988e-05 3.6988e-05
-4.6876e-05 -4.6876e-05
-1.7506e-04 -1.7506e-04
2.3315e-04 2.3315e-04
-2.8747e-04 -2.8747e-04
3.3532e-04 3.3532e-04
-3.7622e-04 -3.7622e-04
-9.6266e-05 -9.6266e-05
1.1798e-04 1.1798e-04
-1.3715e-04 -1.3715e-04
1.5325e-04 1.5325e-04
-1.6656e-04 -1.6656e-04
3.1454e-01 3.1454e-01
1.1106e-01 1.1106e-01
9.7401e-02 9.7401e-02
1.6409e-01 1.6409e-01
5.7574e-02 5.7574e-02
5.0458e-02 5.0458e-02
1.6457e-01 1.6457e-01
5.7787e-02 5.7787e-02
5.0753e-02 5.0753e-02
1.5834e-01 1.5834e-01
5.5924e-02 5.5924e-02
4.9162e-02 4.9162e-02
1.5113e-01 1.5113e-01
5.3697e-02 5.3697e-02
4.7146e-02 4.7146e-02
1.4957e-01 1.4957e-01
5.3154e-02 5.3154e-02
4.6560e-02 4.6560e-02
The above two columns you get should be very similar.
(Left-Your Numerical Gradient, Right-Analytical Gradient)
If your backpropagation implementation is correct, then
the relative difference will be small (less than 1e-9).
Relative Difference: 2.48422e-11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment