Giter Site home page Giter Site logo

textsummarization's Introduction

TextSummarization

Using tensorflow estimator api implement pointer-generator (reference: https://github.com/abisee/pointer-generator)

usage:

def main(_):
    hps = parameters.get_hps()

    # in decode mode, run only one step
    hps_for_predict = None
    if hps.mode == tf.estimator.ModeKeys.PREDICT:
        hps_for_predict = hps
        hps = hps._replace(max_dec_steps=1)

    tf.logging.info(hps)
    estimator = estimator_cfg(hps, model_fn=model_fn)
    input_wrapper = InputFunction(hps)

    if hps.convert_to_coverage_model == True and hps.coverage == True:
        # convert non-coverage to coverage model
        transform_to_coverage_model(hps, estimator)
        exit(0)

    elif hps.mode == tf.estimator.ModeKeys.TRAIN:
        estimator.train(lambda : input_wrapper.input_fn(tf.estimator.ModeKeys.TRAIN), steps=hps.run_step)

    elif hps.mode == tf.estimator.ModeKeys.PREDICT:
        run_infer(input_wrapper, hps_for_predict, estimator)
        
if __name__ == "__main__":
    
    # setting log level
    tf.logging.set_verbosity(tf.logging.INFO)

    # infer mode
    tf.flags.FLAGS.mode = "infer"
    tf.flags.FLAGS.batch_size = 4

    # train mode
    # tf.flags.FLAGS.mode = "train"

    # parameters
    tf.flags.FLAGS.data_dir = "F:/chinese_summarization"
    tf.flags.FLAGS.max_enc_steps = 50
    tf.flags.FLAGS.max_dec_steps = 10
    tf.flags.FLAGS.model_dir = "../model/"
    tf.flags.FLAGS.coverage = True

    # only switch model from non-coverage to coverage
    # tf.flags.FLAGS.convert_to_coverage_model = True

    tf.app.run(main)

textsummarization's People

Contributors

miangangzhen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.