Rewrite in pure theano