Exemplo n.º 1
0
    def test_default_config(self):
        """Test creating Config object"""
        version = 'configs/defaults/binary-cifar-classification.yml'
        cfg = Config(version)

        self.assertIn('data', dir(cfg))
        self.assertIn('model', dir(cfg))
        self.assertIn('network', dir(cfg))
Exemplo n.º 2
0
 def setUpClass(cls):
     version = 'configs/defaults/binary-cifar-classification.yml'
     cls.cfg = Config(version)
     cls.cfg.data['dataset']['params'] = {
         'val': {
             'fraction': 0.1
         }
     }
     cls.cfg.num_workers = 10
Exemplo n.º 3
0
def main(args):
    seed_everything(args.seed)
    config = Config(args.version)

    set_logger(join(config.log_dir, 'train.log'))
    logging.info(args)

    if args.wandb:
        os.environ['WANDB_ENTITY'] = config.entity
        os.environ['WANDB_PROJECT'] = config.project
        os.environ['WANDB_DIR'] = dirname(config.checkpoint_dir)

        run_name = args.version.replace('/', '_')
        wandb.init(name=run_name,
                   dir=dirname(config.checkpoint_dir),
                   notes=config.description,
                   resume=args.resume,
                   id=args.id)
        wandb.config.update(config.__dict__,
                            allow_val_change=config.allow_val_change)

    config.num_workers = args.num_workers
    train(config, args.debug, args.overfit_batch, args.wandb)
Exemplo n.º 4
0
def main(args):
    version = args.version
    config = Config(version)
    version = splitext(version)[0]

    set_logger(join(config.log_dir, 'eval.log'))
    logging.info(args)

    if args.bs is not None:
        config.model['batch_size'] = args.bs

    # add checkpoint loading values
    load_epoch = args.epoch
    load_best = args.best
    config.model['load']['version'] = version
    config.model['load']['epoch'] = load_epoch
    config.model['load']['load_best'] = load_best

    # ensures that the epoch_counter attribute is set to the
    # epoch number being loaded
    config.model['load']['resume_epoch'] = True

    if args.wandb:
        # set up wandb
        os.environ['WANDB_ENTITY'] = config.entity
        os.environ['WANDB_PROJECT'] = config.project
        os.environ['WANDB_DIR'] = dirname(config.checkpoint_dir)

        run_name = '_'.join(['evaluation', version.replace('/', '_')])
        wandb.init(name=run_name,
                   dir=dirname(config.checkpoint_dir),
                   notes=config.description)
        wandb.config.update(config.__dict__)

    config.num_workers = args.num_workers
    evaluate(config, args.mode, args.wandb, args.ignore_cache, args.n_tta)
Exemplo n.º 5
0
print(len(prediction_val), len(val))
print()
    
val = pd.merge(prediction_val, val)
    
print('Performance without using SWA')
val_preds = val['target'].values
val_labels = val['label'].values
roc = roc_auc_score(val_labels, val_preds)
print(roc)


# In[9]:


config = Config(join('/workspace/coreml', config_name + '.yml'))


# In[19]:


set_logger(join(config.log_dir, 'debug.log'))


# In[10]:


val_dataloader, _ = get_dataloader(
        config.data, 'val',
        config.model['batch_size'],
        num_workers=10,