// Provides a way to learn the neural network using the backpropagation
// learning algorithm.
Provides a way to learn the neural network using the backpropagation
learning algorithm.
// Provides a way to learn the neural network using the backpropagation // learning algorithm .
func (b *BackPropagation) Learn(outputs, targets []float64) {
	last := len(b.network.Layers) - 1
	for k, output := range outputs {
		b.deltas[last][k] = output * (1 - output) * (targets[k] - output)
	}
	for h := last; h > 0; h-- {
		computeDeltas(b.network.Layers[h], b.deltas[h-1], b.deltas[h])
	}
	for h := last; h >= 0; h-- {
		updateWeights(b.network.Layers[h], b.deltas[h], b.prevDeltas[h], b.learnRate, b.momentum)
	}
	b.prevDeltas, b.deltas = b.deltas, b.prevDeltas
}
func ( b * BackPropagation ) Learn ( outputs , targets [ ] float64 ) { last := len ( b . network . Layers ) - 1 for k , output := range outputs { b . deltas [ last ] [ k ] = output * ( 1 - output ) * ( targets [ k ] - output ) } for h := last ; h > 0 ; h -- { computeDeltas ( b . network . Layers [ h ] , b . deltas [ h - 1 ] , b . deltas [ h ] ) } for h := last ; h >= 0 ; h -- { updateWeights ( b . network . Layers [ h ] , b . deltas [ h ] , b . prevDeltas [ h ] , b . learnRate , b . momentum ) } b . prevDeltas , b . deltas = b . deltas , b . prevDeltas }
Provides a way to learn the neural network using the backpropagation
learning algorithm.
Provides a way to learn the neural network using the backpropagation learning algorithm .
// Calculate the output layer's deltas // for each output k compute the delta for target t // $$\delta_k \leftarrow o_k (1 - o_k) (t_k - o_k)$$ // Compute the deltas for each layer. // Calculate delta for the nodes feeding this node. No need to process // the first layer in the network because the nodes feeding it are // just inputs // Update the layer's weights using the deltas calculated for each node // Swamp layers so next iteration the current layer will be the previous // and the current previous can be reused.