def gen_predict_graph(predictor): """ call it at last , build predict graph the probelm here is you can not change like beam size later... """ #-----discriminant and generative score = predictor.init_predict() tf.add_to_collection('score', score) if algos_factory.is_discriminant(FLAGS.algo): tf.add_to_collection('textsim_score', predictor.textsim_score) #-----generateive if algos_factory.is_generative(FLAGS.algo): exact_score = predictor.init_predict(exact_loss=True) tf.add_to_collection('exact_score', exact_score) init_predict_text = functools.partial(predictor.init_predict_text, beam_size=FLAGS.beam_size, convert_unk=False) text, text_score = init_predict_text( decode_method=FLAGS.seq_decode_method) beam_text, beam_text_score = init_predict_text( decode_method=SeqDecodeMethod.beam) tf.add_to_collection('text', text) tf.add_to_collection('text_score', text_score) tf.add_to_collection('beam_text', beam_text) tf.add_to_collection('beam_text_score', beam_text_score)
def gen_evalulate(input_app, input_results, predictor, eval_ops, eval_scores, eval_neg_text=None, eval_neg_text_str=None): assert algos_factory.is_discriminant(FLAGS.algo) eval_ops += eval_show.gen_eval_show_ops(input_app, input_results, predictor, eval_scores, eval_neg_text, eval_neg_text_str) deal_eval_results = eval_show.deal_eval_results return eval_ops, deal_eval_results