disp_str = '#{}-{}\ttrain: {:.4f}, {:.2f}% | dev: {:.4f}, {:.2f}% '.format( int(epoch), iter, train_loss, 100 * train_accuracy, dev_loss, 100 * dev_accuracy) for k, v in monitor.items(): disp_str += ' | {}: {:.4f}'.format(k, v / config.eval_period) disp_str += ' \n' monitor = OrderedDict() self.logger.write(disp_str) self.logger.flush() sys.stdout.write(disp_str) sys.stdout.flush() iter += 1 self.iter_cnt += 1 if __name__ == '__main__': parser = argparse.ArgumentParser(description='mnist_trainer.py') parser.add_argument('--suffix', default='run0', type=str, help="Suffix added to the save images.") args = parser.parse_args() trainer = Trainer(config.mnist_config(), args) trainer.train()
default=10, type=int, help="Max Iterations") parser.add_argument('--max_epochs', default=100, type=int, help="Max Epochs") parser.add_argument('--suffix', default='run0', type=str, help="Suffix added to the save directory.") args = parser.parse_args() if args.dataset == 'mnist': conf = config.mnist_config() num_examples = 60000 Trainer = mnist_trainer.Trainer elif args.dataset == 'svhn': conf = config.svhn_config() num_examples = 73257 Trainer = svhn_trainer.Trainer elif args.dataset == 'cifar': conf = config.cifar_config() num_examples = 50000 Trainer = cifar_trainer.Trainer else: raise NotImplementedError conf.log_root = check_folder( conf.log_root +