Пользовательская оценка Tensorflow восстанавливает модель слишком много раз - PullRequest
0 голосов
/ 03 декабря 2018

Часть моего кода выглядит следующим образом:

   model_fn = model_fn_builder(
            bert_config=bert_config,
            init_checkpoint=FLAGS.init_checkpoint,
            layer_indexes=layer_indexes,
            use_tpu=FLAGS.use_tpu,
            use_one_hot_embeddings=FLAGS.use_one_hot_embeddings)

    estimator = Estimator(
            model_fn=model_fn,
            )

    for id in xls_dict:
        features = convert_examples_to_features(examples=examples, seq_length=FLAGS.max_seq_length,tokenizer=tokenizer)
        unique_id_to_feature = {}
        for feature in features:
            unique_id_to_feature[feature.unique_id] = feature
        input_fn = input_fn_builder(
            features=features, seq_length=FLAGS.max_seq_length)
        embs=[]   
        for result in estimator.predict(input_fn, yield_single_examples=True):

Каждый прогноз с estimator.predict моделью восстанавливается, что неэффективно.И model_fn также называется несколько раз как estimator.predict.Что я могу сделать, чтобы избежать этого?

...