Exemplo n.º 1
0
def cli_train(triple_source, config, model_class, optimizer_class):
  data_loader = _build_data_loader_based_on_model(model_class, triple_source, config)
  model = estimate.train(
      triple_source,
      config,
      data_loader,
      model_class,
      optimizer_class,
      drawer=create_drawer(config))
Exemplo n.º 2
0
def cli_profile(triple_source, config, model_class, optimizer_class):
  with torch.autograd.profiler.profile() as prof:
    model = estimate.train(
        triple_source,
        config,
        model_class,
        optimizer_class,
        drawer=create_drawer(config))
  print(prof)
Exemplo n.º 3
0
def cli_train_and_validate(triple_source, config, model_class, optimizer_class,
                           validation_evaluator):
  data_loader = _build_data_loader_based_on_model(model_class, triple_source, config)
  model = estimate.train_and_validate(
      triple_source,
      config,
      data_loader,
      model_class,
      optimizer_class,
      validation_evaluator,
      drawer=create_drawer(config))
Exemplo n.º 4
0
        d.update(changed_config)
        if os.path.exists(
                os.path.join('model_states', changed_config['name'],
                             'checkpoint.pth.tar_1000')):
            continue
        search_config = utils.build_config_with_dict(d)

        utils.seed_modules(config,
                           numpy_seed=10000,
                           torch_seed=20000,
                           torcu_cuda_seed_all=2192,
                           cuda_deterministic=True,
                           kgegrok_base_seed=30000,
                           cuda_benchmark=config.cudnn_benchmark)

        optimizer_class = utils.load_class_from_module(search_config.optimizer,
                                                       'torch.optim')
        data_loader = data.create_dataloader(triple_source, search_config,
                                             model_class.require_labels())
        drawer = stats.create_drawer(search_config)
        model = estimate.train_and_validate(
            triple_source,
            search_config,
            data_loader,
            model_class,
            optimizer_class,
            evaluator=evaluator,
            stat_gather=evaluation.build_stat_gather_from_config(
                config, drawer),
            drawer=drawer)