This implementation is followed by andrew course, and which course url: http://www.stanford.edu/class/cs294a/sparseAutoencoder_2011new.pdf