Refactor feed_forward method to compile theano function on-demand.