def pipeline_onlineExpert(self, epoch): # TODO: del dataloader # create dataloader self.onlineExpert.set_up() self.onlineExpert.computeSolution() self.dataTransformer.set_up(epoch) self.dataTransformer.solutionTransformer() del self.data_loader self.data_loader = DecentralPlannerDataLoader(config=self.config)
def __init__(self, config): super().__init__(config) self.config = config self.onlineExpert = ComputeECBSSolution(self.config) self.dataTransformer = DataTransformer(self.config) self.recorder = MonitoringMultiAgentPerformance(self.config) self.model = DecentralPlannerNet(self.config) self.logger.info("Model: \n".format(print(self.model))) # define data_loader self.data_loader = DecentralPlannerDataLoader(config=config) # define loss self.loss = CrossEntropyLoss() self.l1_reg = L1Regularizer(self.model) self.l2_reg = L2Regularizer(self.model) # define optimizers self.optimizer = optim.Adam(self.model.parameters(), lr=self.config.learning_rate, weight_decay=self.config.weight_decay) print(self.config.weight_decay) self.scheduler = optim.lr_scheduler.CosineAnnealingLR( self.optimizer, T_max=self.config.max_epoch, eta_min=1e-6) # for param in self.model.parameters(): # print(param) # for name, param in self.model.state_dict().items(): # print(name, param) # initialize counter self.current_epoch = 0 self.current_iteration = 0 self.current_iteration_validStep = 0 self.rateReachGoal = 0.0 # set cuda flag self.is_cuda = torch.cuda.is_available() if self.is_cuda and not self.config.cuda: self.logger.info( "WARNING: You have a CUDA device, so you should probably enable CUDA" ) self.cuda = self.is_cuda & self.config.cuda # set the manual seed for torch self.manual_seed = self.config.seed if self.cuda: torch.cuda.manual_seed_all(self.manual_seed) self.config.device = torch.device("cuda") torch.cuda.set_device(self.config.gpu_device) self.model = self.model.to(self.config.device) self.loss = self.loss.to(self.config.device) self.logger.info("Program will run on *****GPU-CUDA***** ") print_cuda_statistics() else: self.config.device = torch.device("cpu") torch.manual_seed(self.manual_seed) self.logger.info("Program will run on *****CPU*****\n") # Model Loading from the latest checkpoint if not found start from scratch. if self.config.train_TL or self.config.test_general: self.load_pretrained_checkpoint(self.config.test_epoch, lastest=self.config.lastest_epoch, best=self.config.best_epoch) else: self.load_checkpoint(self.config.test_epoch, lastest=self.config.lastest_epoch, best=self.config.best_epoch) # Summary Writer self.robot = multiRobotSim(self.config) self.switch_toOnlineExpert = False self.summary_writer = SummaryWriter(log_dir=self.config.summary_dir, comment='NerualMAPP') self.plot_graph = True self.save_dump_input = False self.dummy_input = None self.dummy_gso = None self.time_record = None