Skip to content

Commit fc38c23

Browse files
committed
Revert to error = actual - ideal
1 parent a8a5562 commit fc38c23

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

neural_net.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def train_on_batch inputs, expected_outputs
8585

8686
def calculate_training_error ideal_output
8787
@outputs[output_layer].map.with_index do |output, i|
88-
ideal_output[i] - output
88+
output - ideal_output[i]
8989
end
9090
end
9191

@@ -142,7 +142,8 @@ def update_weights
142142
weight = @weights[layer][neuron][source_neuron]
143143
weight_change = @weight_changes[layer][neuron][source_neuron]
144144
weight_update_value = @weight_update_values[layer][neuron][source_neuron]
145-
gradient = @gradients[layer][neuron][source_neuron]
145+
# for RPROP, we use the negative of the calculated gradient
146+
gradient = -@gradients[layer][neuron][source_neuron]
146147
previous_gradient = @previous_gradients[layer][neuron][source_neuron]
147148

148149
c = sign(gradient * previous_gradient)

0 commit comments

Comments
 (0)