Code for UFLDL Exercise, all tested