separated training from testing and added capability to save weights to file