Implemented feedforward and cost function for neural network