October 2018
Intermediate to advanced
472 pages
10h 57m
English
So, after running the training process for few hours on a GPU, you can see that the accuracy has reached a value of 1.0, and loss has significantly reduced to 0.00045. Let's see how the model performs when we ask some generic questions.
To make predictions, we will create a predict() function that will take the raw text of any size as input and return the response to the question that we asked. We did a quick fix to handle the Out Of Vocab (OOV) words by replacing them with the PAD:
def predict(sentence): X_in = [] for word in sentence.split(): try: X_in.append(dictionary_from[word]) except: X_in.append(PAD) pass test, seq_x = pad_sentence_batch([X_in], PAD) input_batch = np.zeros([batch_size,seq_x[0]]) input_batch[0] ...
Read now
Unlock full access