def main(): """Main function that trains and/or evaluates a model.""" params = interpret_args() # Prepare the dataset into the proper form. data = atis_data.ATISDataset(params) # Construct the model object. model_type = InteractionATISModel if params.interaction_level else ATISModel model = model_type( params, data.input_vocabulary, data.output_vocabulary, data.anonymizer if params.anonymize and params.anonymization_scoring else None) last_save_file = "" if params.train: last_save_file = train(model, data, params) if params.evaluate: evaluate(model, data, params, last_save_file) if params.interactive: interact(model, params, data.anonymizer, last_save_file) if params.attention: evaluate_attention(model, data, params, params.save_file)
def main(): """Main function that trains and/or evaluates a model.""" params = interpret_args() # Prepare the dataset into the proper form. data = atis_data.ATISDataset(params) if params.new_version: #my_vocab = Vocabulary(params.interaction_train, params.interaction_valid) #pickle.dump(my_vocab, open("new_vocab_train", "wb")) my_vocab = pickle.load(open("new_vocab_train", "rb")) print(my_vocab.id2label) print(len(my_vocab)) data.output_vocabulary = my_vocab #new_interaction_train = pickle.load(open("interactions_new_train", "rb")) #new_interaction_valid = pickle.load(open("interactions_new_valid", "rb")) #data.train_data.examples = new_interaction_train #data.valid_data.examples = new_interaction_valid transfer_dataset(data.valid_data, name="valid", maximum=params.train_maximum_sql_length) transfer_dataset(data.train_data, name="train", maximum=params.train_maximum_sql_length) # Construct the model object. model_type = InteractionATISModel if params.interaction_level else ATISModel model = model_type( params, data.input_vocabulary, data.output_vocabulary, data.anonymizer if params.anonymize and params.anonymization_scoring else None) last_save_file = params.save_file if params.train: last_save_file = train(model, data, params, last_save_file) if params.evaluate: evaluate(model, data, params, last_save_file) if params.interactive: interact(model, params, data.anonymizer, last_save_file) if params.attention: evaluate_attention(model, data, params, params.save_file)
def main(): params = interpret_args() data = atis_data.ATISDataset(params)