def test__get_loader_encdec(setup_args): setup_args.model = 'shallow_encdec' train_loader, val_loader = get_dataloaders(setup_args) assert isinstance(train_loader, torch.utils.data.DataLoader) assert isinstance(train_loader.dataset, SeqInSeqOut) assert isinstance(val_loader, torch.utils.data.DataLoader) assert isinstance(val_loader.dataset, SeqInSeqOut)
def test__get_loader_fnn(setup_args): setup_args.model = 'shallow_fnn' train_loader, val_loader = get_dataloaders(setup_args) assert isinstance(train_loader, torch.utils.data.DataLoader) assert isinstance(train_loader.dataset, FlatInFlatOut) assert isinstance(val_loader, torch.utils.data.DataLoader) assert isinstance(val_loader.dataset, FlatInFlatOut)
import torch import torch.optim as optim from motornn.utils.parser import get_parser_with_args from motornn.utils.helpers import (get_file_names, get_dataloaders, get_model, get_loss_function, Log) from motornn.utils.runner import Runner parser = get_parser_with_args() args = parser.parse_args() weight_path, log_path = get_file_names(args) print(weight_path, log_path) logger = Log(log_path, 'w') train_loader, val_loader = get_dataloaders(args) model = get_model(args) criterion = get_loss_function(args) optimizer = optim.SGD(model.parameters(), lr=args.lr) runner = Runner(args.gpu, model, optimizer, criterion, train_loader, val_loader) best_smape = 1000 logger.write_model(model) for epoch in range(args.epochs): runner.set_epoch_metrics() train_metrics = runner.train_model()