def run(args, myargs): my_config = getattr(myargs.config, args.command) config = AugmentConfig() for k, v in args.items(): assert not hasattr(config, k) setattr(config, k, v) for k, v in my_config.items(): if not hasattr(config, k): print('* config does not have %s'%k) setattr(config, k, v) device = torch.device("cuda") writer = myargs.writer writer.add_text('all_config', config.as_markdown(), 0) logger = myargs.logger config.print_params(logger.info_msg) config.genotype = gt.from_str(config.genotype) config.data_path = os.path.expanduser(config.data_path) config.plot_path = os.path.join(args.outdir, 'plot') config.path = args.outdir main(config=config, logger=logger, device=device, myargs=myargs)
""" Training augmented model """ import torch.nn as nn import torchvision from tensorboardX import SummaryWriter from config import AugmentConfig import utils from models.augment_cnn import AugmentCNN from utils import * config = AugmentConfig() device = torch.device("cuda") # tensorboard writer = SummaryWriter(log_dir=os.path.join(config.path, "tb")) writer.add_text('config', config.as_markdown(), 0) logger = utils.get_logger( os.path.join(config.path, "{}.log".format(config.name))) config.print_params(logger.info) def main(): logger.info("Logger is set - training start") logger.info("Torch version is: {}".format(torch.__version__)) logger.info("Torch_vision version is: {}".format(torchvision.__version__)) # set default gpu device id torch.cuda.set_device(config.gpus[0]) # set seed
import os import torch import torch.nn as nn import numpy as np from tensorboardX import SummaryWriter from config import AugmentConfig import utils from models.augment_cnn import AugmentCNN, AugmentCNNImageNet config = AugmentConfig() device = torch.device("cuda") # tensorboard writer = SummaryWriter(log_dir=os.path.join(config.path, "tb")) writer.add_text("config", config.as_markdown(), 0) logger = utils.get_logger( os.path.join(config.path, "{}.log".format(config.name))) config.print_params(logger.info) def main(): logger.info("Logger is set - training start") # set default gpu device id torch.cuda.set_device(config.gpus[0]) # set seed np.random.seed(config.seed) torch.manual_seed(config.seed)