Beispiel #1
0
 def child_process(curr_step):
     print('Starting child process')
     model = RNNModel.Builder().set_max_steps(max_steps). \
         set_word_feature_size(word_feature_size + pos_feature_size). \
         set_read_path(os.path.join('records','eval')). \
         set_epochs(1). \
         set_char_emb_status(use_char_embeddings). \
         set_cell_type(RNNModel.CellType.RNN_CELL_TYPE_GRU). \
         set_cell_size(cell_size). \
         set_batch_size(batch_size). \
         set_class_size(num_classes). \
         set_entity_class_size(num_entity_classes) .\
         set_layer_size(num_layers). \
         set_model_path(model_path). \
         set_model_name(model_name).\
         set_logs_path(logs_path). \
         set_bi_directional(bi_directional). \
         set_classifer_status(is_classifer). \
         set_state_feedback(state_feeback). \
         set_time_major(time_major).\
         set_char_feature_size(char_feature_size).\
         set_char_cell_size(char_cell_size).\
         set_char_vocab_size(char_vocab_size).\
         set_oper_mode(RNNModel.OperMode.OPER_MODE_EVAL). \
         build()
     model.evaluate(curr_step=curr_step)
Beispiel #2
0
        thread.start()
        thread.join()

        # eval_model.evaluate()

    train_model = RNNModel.Builder().set_max_steps(max_steps).\
        set_feature_size(feature_size).\
        set_read_path(os.path.join('records', 'train')). \
        set_epochs(train_epochs).\
        set_cell_type(cell_type).\
        set_cell_size(cell_size).\
        set_batch_size(batch_size).\
        set_class_size(num_classes).\
        set_layer_size(num_layers).\
        set_learning_rate(learning_rate). \
        set_model_path(model_path). \
        set_model_name(model_name). \
        set_logs_path(logs_path).\
        set_eval_fn(evaluator). \
        set_time_major(time_major). \
        set_state_feedback(state_feeback). \
        set_bi_directional(bi_directional) .\
        set_classifer_status(is_classifer).\
        set_oper_mode(RNNModel.OperMode.OPER_MODE_TRAIN). \
        set_validation_step(validation_step).\
        build()

    train_model.train(keep_prob)

#         set_eval_fn(evaluator). \
Beispiel #3
0
import numpy as np
from utils import preprocess_data
from paths import *

if __name__ == '__main__':

    model = RNNModel.Builder().set_max_steps(max_steps). \
        set_word_feature_size(word_feature_size + pos_feature_size). \
        set_cell_type(RNNModel.CellType.RNN_CELL_TYPE_GRU). \
        set_cell_size(cell_size). \
        set_batch_size(1). \
        set_class_size(num_classes). \
        set_entity_class_size(num_entity_classes). \
        set_layer_size(num_layers). \
        set_model_path(model_path). \
        set_model_name(model_name). \
        set_time_major(time_major).\
        set_bi_directional(bi_directional). \
        set_state_feedback(state_feeback). \
        set_classifer_status(is_classifer). \
        set_char_feature_size(char_feature_size). \
        set_char_cell_size(char_cell_size). \
        set_char_vocab_size(char_vocab_size). \
        set_oper_mode(RNNModel.OperMode.OPER_MODE_TEST). \
        build()

    model.init_graph()

    nlp = spacy.load(spacy_model_path)
    nlp_pos = spacy.load('en_core_web_sm')
Beispiel #4
0
        # eval_model.evaluate()

    train_model = RNNModel.Builder().set_max_steps(max_steps). \
        set_char_emb_status(use_char_embeddings) .\
        set_word_feature_size(word_feature_size + pos_feature_size).\
        set_read_path(os.path.join('records', 'train')). \
        set_epochs(train_epochs).\
        set_cell_type(RNNModel.CellType.RNN_CELL_TYPE_GRU).\
        set_cell_size(cell_size).\
        set_batch_size(batch_size).\
        set_class_size(num_classes). \
        set_entity_class_size(num_entity_classes). \
        set_layer_size(num_layers).\
        set_learning_rate(learning_rate). \
        set_model_path(model_path). \
        set_model_name(model_name). \
        set_logs_path(logs_path).\
        set_eval_fn(evaluator). \
        set_time_major(time_major). \
        set_state_feedback(state_feeback). \
        set_bi_directional(bi_directional) .\
        set_classifer_status(is_classifer).\
        set_char_feature_size(char_feature_size).\
        set_char_cell_size(char_cell_size). \
        set_char_vocab_size(char_vocab_size). \
        set_oper_mode(RNNModel.OperMode.OPER_MODE_TRAIN). \
        set_validation_step(validation_step).\
        build()

    train_model.train(keep_prob)
Beispiel #5
0
config.set_string('-hmm', os.path.join(modeldir, r'en-us\en-us'))
config.set_string('-dict', os.path.join(modeldir, r'en-us\cmudict-en-us.dict'))
config.set_string('-keyphrase', 'alexa')
config.set_float('-kws_threshold', 1e-20)
config.set_string('-logfn', 'null')

decoder = Decoder(config)
decoder.start_utt()

model = RNNModel.Builder().set_max_steps(max_steps). \
    set_feature_size(feature_size). \
    set_cell_type(RNNModel.CellType.RNN_CELL_TYPE_GRU). \
    set_cell_size(cell_size). \
    set_batch_size(batch_size). \
    set_class_size(num_classes). \
    set_layer_size(num_layers). \
    set_model_path(model_path). \
    set_model_name(model_name). \
    set_time_major(time_major).\
    set_classifer_status(is_classifer). \
    set_oper_mode(RNNModel.OperMode.OPER_MODE_TEST). \
    build()

model.init_graph()

data = b''
batch_count = 15
count = 0


def evaluator():