示例#1
0
def run_report_results(args, probe, dataset, model, loss, reporter, regimen):
    """
    Reports results from a structural probe according to args.
    By default, does so only for dev set.
    Requires a simple code change to run on the test set.
    """
    probe_params_path = os.path.join(args['reporting']['root'],
                                     args['probe']['params_path'])
    probe.load_state_dict(torch.load(probe_params_path))
    probe.eval()

    dev_dataloader = dataset.get_dev_dataloader()
    dev_predictions = regimen.predict(probe, model, dev_dataloader)
    dev_report = reporter(dev_predictions, dev_dataloader, 'dev', probe=probe)

    #train_dataloader = dataset.get_train_dataloader(shuffle=False)
    #train_predictions = regimen.predict(probe, model, train_dataloader)
    #reporter(train_predictions, train_dataloader, 'train')

    # Uncomment to run on the test set
    test_dataloader = dataset.get_test_dataloader()
    test_predictions = regimen.predict(probe, model, test_dataloader)
    test_report = reporter(test_predictions,
                           test_dataloader,
                           'test',
                           probe=probe)
    return dev_report, test_report
示例#2
0
def run_report_results(args, probe, dataset, model, loss, reporter, regimen):
  """
  Reports results from a structural probe according to args.
  By default, does so only for dev set.
  Requires a simple code change to run on the test set.
  """
  probe_params_path = os.path.join(args['reporting']['root'],args['probe']['params_path'])
  probe.load_state_dict(torch.load(probe_params_path))
  probe.eval()

  dev_dataloader = dataset.get_dev_dataloader()
  dev_predictions = regimen.predict(probe, model, dev_dataloader)
  reporter(dev_predictions, dev_dataloader, 'dev')
示例#3
0
def run_report_results(args, probe, dataset, model, loss, reporter, regimen):
    probe_params_path = os.path.join(args['reporting']['root'],
                                     args['probe']['params_path'])
    dev_dataloader = dataset.get_dev_dataloader()
    try:
        probe.load_state_dict(torch.load(probe_params_path))
        probe.eval()
        dev_predictions = regimen.predict(probe, model, dev_dataloader)
    except FileNotFoundError:
        print("No trained probe found.")
        dev_predictions = None

    reporter(dev_predictions, probe, model, dev_dataloader, 'dev')