neural net rewrite