Skip to content

Commit

Permalink
Update galaktaglare.go
Browse files Browse the repository at this point in the history
  • Loading branch information
simplyYan authored Jan 26, 2024
1 parent 4f888e2 commit 2afe147
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion galaktaglare.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,24 @@ func (nn *NeuralNetwork) Backpropagate(output, target []float64, learningRate fl
layer.Biases[j] -= learningRate * outputError[j] * activationGradient[j]
}

outputError = nn.MultiplyVectors(layer.Weights, outputError)
outputError = nn.MultiplyMatrixVector(layer.Weights, outputError)
}
}

func (nn *NeuralNetwork) MultiplyMatrixVector(matrix [][]float64, vector []float64) []float64 {
rows := len(matrix)
cols := len(matrix[0])
result := make([]float64, rows)

for i := 0; i < rows; i++ {
for j := 0; j < cols; j++ {
result[i] += matrix[i][j] * vector[j]
}
}

return result
}

func (nn *NeuralNetwork) MultiplyVectors(v1 []float64, v2 []float64) []float64 {
result := make([]float64, len(v1))
for i := range v1 {
Expand Down

0 comments on commit 2afe147

Please sign in to comment.