You need an error signal - a target value is compared with the networks prediction.
That error is carefully assigned proportionally to the network weights that contributed to it and the weights adjusted a small amount in that direction.
This is repeated many times.
Backpropagation suffers from vanishing gradients on very deep neural nets.
Recurrent Neural Nets can be very deep in time.
Or the weights could be evolved using Genetic Programming.
> Or the weights could be evolved using Genetic Programming.
Some algorithms, such as NEAT[0], use a genetic algorithm to describe not only the weights on edges in the network, but also the shape of the network itself - e.g., instead of every node of one layer connected to every node of the next, only certain connections are made.
It would also be ideal to use a higher level interpreted language, and have it try to generate one page scripts rather than giant mega projects like linux.