Wrote neural network function.