Imported from https://github.com/marcellacornia/mlnet