예제 #1
0
def main(_):
    tf_logging.info("Train albert")
    config = JsonConfig.from_json_file(FLAGS.model_config_file)
    train_config = TrainConfigEx.from_flags(FLAGS)
    input_fn = input_fn_from_flags(input_fn_builder_classification, FLAGS)
    model_fn = model_fn_classification(config, train_config, Albert.factory)
    return run_estimator(model_fn, input_fn)
예제 #2
0
def main(_):
    tf_logging.info("Run generative predictor")
    config = JsonConfig.from_json_file(FLAGS.model_config_file)
    train_config = TrainConfigEx.from_flags(FLAGS)
    input_fn = input_fn_from_flags(input_fn_builder_classification, FLAGS)
    model_fn = model_fn_generative_predictor(config, train_config)
    return run_estimator(model_fn, input_fn)
예제 #3
0
def main(_):
    tf_logging.info("Train horizon classification")
    config = JsonConfig.from_json_file(FLAGS.model_config_file)
    train_config = TrainConfigEx.from_flags(FLAGS)
    input_fn = input_fn_from_flags(input_fn_builder_classification, FLAGS)
    model_fn = model_fn_classification(config, train_config,
                                       BertologyFactory(HorizontalAlpha))
    return run_estimator(model_fn, input_fn)
예제 #4
0
파일: gs_tpu.py 프로젝트: clover3/Chair
def main_inner():
    train_config = TrainConfigEx.from_flags(FLAGS)
    model_fn = model_fn_classification(
        train_config=train_config,
    )
    input_fn = input_fn_from_flags(input_fn_builder, FLAGS)
    r = run_estimator(model_fn, input_fn)
    return r
예제 #5
0
def main(_):
    config = JsonConfig.from_json_file(FLAGS.bert_config_file)
    sero_config = JsonConfig.from_json_file(FLAGS.model_config_file)
    train_config = TrainConfigEx.from_flags(FLAGS)
    input_fn = input_fn_from_flags(input_fn_builder_classification, FLAGS)
    model_fn = model_fn_classification(config, train_config,
                                       partial(DualSeroBertModel, sero_config),
                                       FLAGS.special_flags.split(","))
    return run_estimator(model_fn, input_fn)
예제 #6
0
def main(_):
    config = JsonConfig.from_json_file(FLAGS.model_config_file)
    train_config = TrainConfigEx.from_flags(FLAGS)

    input_fn = input_fn_from_flags(input_fn_builder_classification, FLAGS)

    model_fn = model_fn_classification(config, train_config, BertModel)
    r = run_estimator(model_fn, input_fn)
    return r
예제 #7
0
def main(_):
    tf_logging.info("Classification with alt loss")
    config = JsonConfig.from_json_file(FLAGS.model_config_file)
    train_config = TrainConfigEx.from_flags(FLAGS)
    input_fn = input_fn_from_flags(input_fn_builder_classification, FLAGS)

    model_fn = model_fn_classification_with_alt_loss(config, train_config, BertModel)
    if FLAGS.do_predict:
        tf_logging.addFilter(MuteEnqueueFilter())

    return run_estimator(model_fn, input_fn)
예제 #8
0
def main(_):
    bert_config = modeling.BertConfig.from_json_file(FLAGS.bert_config_file)
    input_files = flags_wrapper.get_input_files()
    train_config = TrainConfigEx.from_flags(FLAGS)
    show_input_files(input_files)
    model_fn = model_fn_explain(
        bert_config=bert_config,
        train_config=train_config,
        logging=tf_logging,
    )
    input_fn = input_fn_from_flags(input_fn_builder_classification, FLAGS)
    r = run_estimator(model_fn, input_fn)
    return r
예제 #9
0
def run_w_data_id():
    input_files = get_input_files_from_flags(FLAGS)
    bert_config = BertConfig.from_json_file(FLAGS.bert_config_file)
    train_config = TrainConfigEx.from_flags(FLAGS)
    show_input_files(input_files)
    model_fn = model_fn_classification_for_lr_debug(
        bert_config,
        train_config,
    )
    if FLAGS.do_predict:
        tf_logging.addFilter(CounterFilter())
    input_fn = input_fn_from_flags(input_fn_builder_classification, FLAGS)

    result = run_estimator(model_fn, input_fn)
    return result
예제 #10
0
def main(_):
    bert_config = modeling.BertConfig.from_json_file(FLAGS.bert_config_file)
    train_config = TrainConfigEx.from_flags(FLAGS)

    model_class = BertModel

    special_flags = FLAGS.special_flags.split(",")
    model_fn = model_fn_ranking_ndcg(
        bert_config=bert_config,
        train_config=train_config,
        model_class=model_class,
        special_flags=special_flags,
    )

    input_fn = input_fn_from_flags(input_fn_builder, FLAGS)
    r = run_estimator(model_fn, input_fn)
    return r
예제 #11
0
def main_inner(model_class=None):
    bert_config = modeling.BertConfig.from_json_file(FLAGS.bert_config_file)
    train_config = TrainConfigEx.from_flags(FLAGS)

    if model_class is None:
        model_class = BertModel

    special_flags = FLAGS.special_flags.split(",")
    model_fn = model_fn_classification(
        bert_config=bert_config,
        train_config=train_config,
        model_class=model_class,
        special_flags=special_flags,
    )

    input_fn = input_fn_from_flags(input_fn_builder, FLAGS)
    r = run_estimator(model_fn, input_fn)
    return r
예제 #12
0
def run_classification_task(model_class):
    config = JsonConfig.from_json_file(FLAGS.model_config_file)
    train_config = TrainConfigEx.from_flags(FLAGS)
    input_fn = input_fn_from_flags(input_fn_builder_classification, FLAGS)
    model_fn = model_fn_classification(config, train_config, model_class, FLAGS.special_flags.split(","))
    return run_estimator(model_fn, input_fn)