Refactored training and objective functions out of MLP for easy composition