Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dlidstrom committed Dec 12, 2023
1 parent dd1e2dc commit a28417a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions CSharp/Neural.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ public void Train (double[] input, double[] y, double lr)
}
}

for (int c = 0; c < GradOutput.Length; c++)
for (int c = 0; c < Network.OutputCount; c++)
{
Network.BiasesOutput[c] -= lr * GradOutput[c];
}

for (int c = 0; c < GradHidden.Length; c++)
for (int c = 0; c < Network.HiddenCount; c++)
{
Network.BiasesHidden[c] -= lr * GradHidden[c];
}
Expand Down
4 changes: 2 additions & 2 deletions Cpp/neural.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ void Trainer::Train(const Vector& input, const Vector& y, double lr) {
}
}

for (size_t c = 0; c < gradOutput.size(); c++) {
for (size_t c = 0; c < network.outputCount; c++) {
network.biasesOutput[c] -= lr * gradOutput[c];
}

for (size_t c = 0; c < gradHidden.size(); c++) {
for (size_t c = 0; c < network.hiddenCount; c++) {
network.biasesHidden[c] -= lr * gradHidden[c];
}
}
4 changes: 2 additions & 2 deletions FSharp/Neural.fs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ type Trainer(network, n_inputs, n_hidden, n_outputs) =
for c = 0 to n_hidden - 1 do
network.WeightsHidden[r * n_hidden + c] <- network.WeightsHidden[r * n_hidden + c] - lr * grad_hidden[c] * input[r]

for c = 0 to grad_output.Length - 1 do
for c = 0 to n_outputs - 1 do
network.BiasesOutput[c] <- network.BiasesOutput[c] - lr * grad_output[c]

for c = 0 to grad_hidden.Length - 1 do
for c = 0 to n_hidden - 1 do
network.BiasesHidden[c] <- network.BiasesHidden[c] - lr * grad_hidden[c]
4 changes: 2 additions & 2 deletions Rust/src/neural.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ impl Trainer {
}
}

for c in 0..self.grad_output.len() {
for c in 0..self.network.n_outputs {
self.network.biases_output[c] -= lr * self.grad_output[c];
}

for c in 0..self.grad_hidden.len() {
for c in 0..self.network.n_hidden {
self.network.biases_hidden[c] -= lr * self.grad_hidden[c];
}
}
Expand Down

0 comments on commit a28417a

Please sign in to comment.