From 331f07a70a8375961427b8cc2ac700ddce3a19f7 Mon Sep 17 00:00:00 2001 From: erayon Date: Mon, 29 Jan 2018 10:19:45 +0530 Subject: [PATCH] encode_pickle_error --- code/predict.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/code/predict.py b/code/predict.py index 087db5e..aa2d435 100644 --- a/code/predict.py +++ b/code/predict.py @@ -16,7 +16,6 @@ import helper_dataset as hd import DatasetCliner_experimental as Exp import entity_lstm as entity_model - import tools from model import ClinerModel, write from notes.documents import Document @@ -99,7 +98,8 @@ def predict(files, model_path, output_dir, format,use_lstm=True): # Load model #if use_lstm==False: with open(model_path, 'rb') as f: - model = pickle.load(f) + model = pickle.load(f,encoding = 'latin1') + if use_lstm==True: #model._pretrained_dataset=None @@ -116,7 +116,7 @@ def predict(files, model_path, output_dir, format,use_lstm=True): note=Document(txt) tokenized_sents = note.getTokenizedSentences() updating_notes+=tokenized_sents - #print (updating_notes) + print (updating_notes) fictional_labels= copy.deepcopy(tokenized_sents) @@ -137,18 +137,19 @@ def predict(files, model_path, output_dir, format,use_lstm=True): parameters['Feature_vector_length']=dataset.feature_vector_size parameters['use_features_before_final_lstm']=False dataset.update_dataset("", ['deploy'],Datasets_tokens,Datasets_labels) - ''' - # model._pretrained_dataset=dataset - # model_LSTM=entity_model.EntityLSTM(dataset,parameters) - # model._current_model=model_LSTM - #._current_model + model._pretrained_dataset=dataset + model_LSTM=entity_model.EntityLSTM(dataset,parameters) + model._current_model=model_LSTM + ._current_model + + ''' print ("END TEST") #exit() - # model.parameters=None + #model.parameters=None # Tell user if not predicting if not files: