Merged code from Ole Winther. Thanks! Adds linear and softmax ouput neurons to NN