예제 #1
0
def constrcut_predictor(path):
    # warm_start_from=tf.estimator.WarmStartSettings(
    #     ckpt_to_initialize_from=str(path),
    #    vars_to_warm_start=".*" # everything in TRAINABLE_VARIABLES - excluding optimiser params
    #     # vars_to_warm_start=[".*"], # everything in GLOBAL_VARIABLES - including optimiser params
    # )
    model = LISAModel(hparams, model_config, layer_task_config, layer_attention_config, feature_idx_map, label_idx_map,
                      vocab)
    # ws = WarmStartSettings(ckpt_to_initialize_from=path,
    #                   vars_to_warm_start=".*")
    # print("debug <loading from>:", path)
    estimator = tf.estimator.Estimator(model_fn=model.model_fn, model_dir=path)
    return estimator
예제 #2
0
파일: evaluate.py 프로젝트: yiyouls/LISA
#                        ('feature' in data_config[d] and data_config[d]['feature']) or
#                        ('label' in data_config[d] and data_config[d]['label'])]):
#   if 'feature' in data_config[f] and data_config[f]['feature']:
#     feature_idx_map[f] = i
#   if 'label' in data_config[f] and data_config[f]['label']:
#     if 'type' in data_config[f] and data_config[f]['type'] == 'range':
#       idx = data_config[f]['conll_idx']
#       j = i + idx[1] if idx[1] != -1 else -1
#       label_idx_map[f] = (i, j)
#     else:
#       label_idx_map[f] = (i, i+1)
feature_idx_map, label_idx_map = util.load_feat_label_idx_maps(data_config)

# Initialize the model
model = LISAModel(hparams, model_config, layer_task_config,
                  layer_attention_config, feature_idx_map, label_idx_map,
                  vocab)
tf.logging.log(
    tf.logging.INFO, "Created model with %d trainable parameters" %
    tf_utils.get_num_trainable_parameters())

# Set up the Estimator
estimator = tf.estimator.Estimator(model_fn=model.model_fn,
                                   model_dir=args.save_dir)


def dev_input_fn():
    return train_utils.get_input_fn(vocab,
                                    data_config,
                                    dev_filenames,
                                    hparams.batch_size,