예제 #1
0
def aspectExtractor(sentence):
    # create instance of config
    config = Config()

    # build model
    model = ASPECTModel(config)
    model.build()
    model.restore_session(config.dir_model)

    # create dataset
    test  = CoNLLDataset(config.filename_test, config.processing_word,
                         config.processing_tag, config.max_iter)

    # evaluate and interact
    model.evaluate(test)
    preds=interactive_shell(model , sentence)
    return preds
예제 #2
0
파일: asp_ext_api.py 프로젝트: kz-sher/fyp
def init():
    """
    This function is to load the trained Keras model.
    :return - None
    """
    # load the pre-trained tensorflow model
    global model, graph

    # create instance of config
    config = Config()

    # build model
    model = ASPECTModel(config)
    model.build()
    model.restore_session(config.dir_model)
    graph = tf.get_default_graph()
예제 #3
0
파일: evaluate.py 프로젝트: kz-sher/fyp
def main():
    # create instance of config
    config = Config()

    # build model
    model = ASPECTModel(config)
    model.build()
    model.restore_session(config.dir_model)

    # create dataset
    test  = GloveDataset(config.filename_test, config.processing_word,
                         config.processing_tag, config.max_iter)

    # evaluate and interact
    model.evaluate(test)

    # saver = tf.train.Saver()

    # save_path = saver.save(sess, "/export/model.ckpt")

    # print("Model saved")

    interactive_shell(model)
예제 #4
0
def main():
    # create instance of config
    config = Config()

    # build model
    model = ASPECTModel(config)
    model.build()
    # model.restore_session("results/crf/model.weights/") # optional, restore weights
    # model.reinitialize_weights("proj")

    # create datasets
    dev = CoNLLDataset(config.filename_dev, config.processing_word,
                       config.processing_tag, config.max_iter)
    train = CoNLLDataset(config.filename_train, config.processing_word,
                         config.processing_tag, config.max_iter)

    # train model
    model.train(train, dev)