forked from a neural network gist by @amueller