def log_trial_end(self, trial, failed): e = CNVRGExperiment(self._cnvrg_experiments[trial.trial_id]) e.log("===== Logging Artifacts =====") from os import listdir files_list = [ os.path.join(trial.logdir, p) for p in os.listdir(trial.logdir) ] e.log_artifacts(files_list) e.finish(exit_status=int(failed))
# Name generator names = get_images_name(os.path.join(args.evalf, "images")) model.eval() with torch.no_grad(): for data, target in eval_loader: data, target = data.to(device), target.to(device) output = model(data) label = output.argmax(dim=1, keepdim=True).item() print ("Images: " + next(names) + ", Classified as: " + str(label)) # Train? if args.train: # Train + Test per epoch for epoch in range(1, args.epochs + 1): train(args, model, device, train_loader, optimizer, epoch) accuracy = test(args, model, device, test_loader, epoch) # Do checkpointing - Is saved in outf outfile = '%s/mnist_convnet_model_epoch_%d.pth' % (args.outf, args.epochs) torch.save(model.state_dict(), outfile) e.log_artifacts([outfile]) # Evaluate? if args.evaluate: accuracy = test_image() e.log_param("accuracy", accuracy) e.finish()