def main(): # Get command line arguments args = parse_arguments() hyperparameters = {"epochs": args.epochs, "batch_size": args.batch_size} # Create path for training summaries summary_path = None if args.logdir is not None: summary_path = f"{SUMMARIES_PATH}/{args.logdir}" os.makedirs(summary_path, exist_ok=True) # TODO: Add GPU support. This line of code might be helpful. # device = torch.device("cuda" if torch.cuda.is_available() else "cpu") print("Summary path:", summary_path) print("Epochs:", args.epochs) print("Batch size:", args.batch_size) # Initalize dataset and model. Then train the model! train_dataset = StartingDataset() val_dataset = StartingDataset() model = StartingNetwork() starting_train( train_dataset=train_dataset, val_dataset=val_dataset, model=model, hyperparameters=hyperparameters, n_eval=args.n_eval, summary_path=summary_path, )
def main(): # Get command line arguments args = parse_arguments() hyperparameters = {"epochs": args.epochs, "batch_size": args.batch_size} # Create path for training summaries label = f"cassava__{int(time.time())}" summary_path = f"{SUMMARIES_PATH}/{label}" os.makedirs(summary_path, exist_ok=True) device = torch.device("cuda" if torch.cuda.is_available() else "cpu") print("Summary path:", summary_path) print("Epochs:", args.epochs) print("Batch size:", args.batch_size) # Initalize dataset and model. Then train the model! train_dataset = TransferTrainDataset() val_dataset = TransferValidationDataset() model = StartingNetwork(3, 224, 224, 5) starting_train( train_dataset=train_dataset, val_dataset=val_dataset, model=model, hyperparameters=hyperparameters, n_eval=args.n_eval, summary_path=summary_path, )
def main(): images_dir = "./cassava-leaf-disease-classification/train_images" # Get command line arguments args = parse_arguments() hyperparameters = { "epochs": args.epochs, "batch_size": args.batch_size, "weight_decay": args.weight_decay } # Create path for training summaries label = f"cassava__{int(time.time())}" summary_path = f"{SUMMARIES_PATH}/{label}" os.makedirs(summary_path, exist_ok=True) # TODO: Add GPU support. This line of code might be helpful. device = torch.device("cuda" if torch.cuda.is_available() else "cpu") #print(torch.cuda.get_device_name(0)) print("Summary path:", summary_path) print("Epochs:", args.epochs) print("Batch size:", args.batch_size) # Initalize dataset and model. Then train the model! train_dataset = StartingDataset(images_dir, 'train.csv') val_dataset = StartingDataset(images_dir, 'val.csv') model = ConvNet(num_classes, args.network, args.p_dropout) #train_dataset.__showitem__(0) #print(model) starting_train(train_dataset=train_dataset, val_dataset=val_dataset, model=model, hyperparameters=hyperparameters, n_eval=args.n_eval, summary_path=summary_path, device=device, usePretrained=args.use_pretrained)
def main(): # Get command line arguments args = parse_arguments() hyperparameters = { "epochs": args.epochs, "batch_size": args.batch_size, "weight_decay": args.l2 } # Create path for training summaries label = f"cassava__{int(time.time())}" summary_path = f"{SUMMARIES_PATH}/{label}" os.makedirs(summary_path, exist_ok=True) if torch.cuda.is_available(): device = torch.device("cuda:0") else: device = torch.device("cpu") print("Summary path:", summary_path) print("Epochs:", args.epochs) print("Batch size:", args.batch_size) # Initalize dataset and model. Then train the model! train_dataset = AugmentedDataset(train=True) val_dataset = AugmentedDataset(train=False) model = FullResNextModel(5).to(device) starting_train( train_dataset=train_dataset, val_dataset=val_dataset, model=model, hyperparameters=hyperparameters, n_eval=args.n_eval, summary_path=summary_path, device=device, ) torch.save(model.state_dict(), f'./model-{datetime.now().strftime("%m-%d-%Y_%H-%M-%S")}.pt')