num_workers=2) # 学習と評価 model = training.process(trainloader, testloader, MODEL, args.epochs, args.lr, lr_scheduling=LR_SCHEDULING, log_savepath=TRAIN_LOG_PATH) # 学習結果の可視化 train_losses, test_losses, train_accs, test_accs = tools.load_train_log( path=TRAIN_LOG_PATH) plot.plot_loss(train_losses, test_losses, savepath=LOSS_PLOT_RESULT_PATH) plot.plot_acc(train_accs, test_accs, savepath=ACC_PLOT_RESULT_PATH) # 訓練誤差収束速度の評価 train_err_speed = eval_loss.eval_err_speed(train_losses) test_err_speed = eval_loss.eval_err_speed(test_losses) eval_loss.save(savepath=ERR_SPEED_SAVE_PATH, train_err_speed=train_err_speed, test_err_speed=test_err_speed) print("train loss error speed: {0}".format(train_err_speed)) print("test loss error speed: {0}".format(test_err_speed)) # 学習の設定値を記録 net_name = MODEL.__class__.__name__ argument.save_args(args, LEARN_SETTINGS_PATH, net=net_name,
batch_size=args.batch_size, shuffle=True, num_workers=2) print("number of train data: {0}".format(len(train))) # テストデータの生成 test = preprocess.load_dataset(dataset_dir=TEST_DIR, dataN=args.dataN // 4, imsize=(32, 32)) testloader = torch.utils.data.DataLoader(test, batch_size=args.batch_size, shuffle=True, num_workers=2) print("number of train data: {0}".format(len(test))) # 学習と評価 model = net.LeNet(2) model = training.process(trainloader, testloader, model, args.epochs, args.lr, log_savepath=LOG_SAVEPATH) torch.save(model.state_dict(), MODEL_SAVEPATH) # 学習結果の可視化 train_losses, test_losses, train_accs, test_accs = log_loader.load_log( path=LOG_SAVEPATH) plot.plot_loss(train_losses, test_losses, savepath=LOSS_SAVEPATH) plot.plot_acc(train_accs, test_accs, savepath=ACC_SAVEPATH)