def get_trainer(model, optimizer, cfg, device, **kwargs): ''' Returns the trainer object. Args: model (nn.Module): the Occupancy Network model optimizer (optimizer): pytorch optimizer object cfg (dict): imported yaml config device (device): pytorch device ''' threshold = cfg['test']['threshold'] out_dir = cfg['training']['out_dir'] vis_dir = os.path.join(out_dir, 'vis') input_type = cfg['data']['input_type'] trainer = training.Trainer(model, optimizer, cfg, device=device, input_type=input_type, vis_dir=vis_dir, threshold=threshold, eval_sample=cfg['training']['eval_sample'], uda_type=cfg['training']['uda_type'], num_epochs=cfg['training']['num_epochs']) return trainer
def get_trainer(model, optimizer, cfg, device, **kwargs): ''' Returns the trainer object. Args: model (nn.Module): the Occupancy Network model optimizer (optimizer): pytorch optimizer object cfg (dict): imported yaml config device (device): pytorch device ''' threshold = cfg['test']['threshold'] out_dir = cfg['training']['out_dir'] vis_dir = os.path.join(out_dir, 'vis') input_type = cfg['data']['input_type'] if 'surface_loss_weight' in cfg['model']: surface_loss_weight = cfg['model']['surface_loss_weight'] else: surface_loss_weight = 1. if ('loss_tolerance_episolon' in cfg['training']) and ( 0 in cfg['training']['loss_tolerance_episolon']): loss_tolerance_episolon = cfg['training']['loss_tolerance_episolon'][0] else: loss_tolerance_episolon = 0. if ('sign_lambda' in cfg['training']) and (0 in cfg['training']['sign_lambda']): sign_lambda = cfg['training']['sign_lambda'][0] else: sign_lambda = 0. trainer = training.Trainer(model, optimizer, device=device, input_type=input_type, vis_dir=vis_dir, threshold=threshold, eval_sample=cfg['training']['eval_sample'], surface_loss_weight=surface_loss_weight, loss_tolerance_episolon=loss_tolerance_episolon, sign_lambda=sign_lambda) if 'loss_type' in cfg['training']: trainer.loss_type = cfg['training']['loss_type'] print('loss type:', trainer.loss_type) return trainer
def get_trainer(model, optimizer, cfg): ''' Returns the trainer object. Args: model (tf.keras.Model): the Occupancy Network model optimizer (optimizer): tf.keras.optimizers object cfg (dict): imported yaml config ''' threshold = cfg['test']['threshold'] out_dir = cfg['training']['out_dir'] vis_dir = os.path.join(out_dir, 'vis') input_type = cfg['data']['input_type'] trainer = training.Trainer( model, optimizer, input_type=input_type, vis_dir=vis_dir, threshold=threshold, eval_sample=cfg['training']['eval_sample'], ) return trainer