Created
February 3, 2019 11:59
-
-
Save jainanchit51/4ca7b90a8ba8e761d7d78e774d56a9d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import tensorflow as tf | |
from keras import backend as K | |
q1 = input("Type Question 1 here -->") | |
q2 = input("Type Question 2 here -->") | |
q1 = np.array([[q1],[q1]]) | |
q2 = np.array([[q2],[q2]]) | |
# Using the same tensorflow session for embedding the test string | |
with tf.Session() as session: | |
K.set_session(session) | |
session.run(tf.global_variables_initializer()) | |
session.run(tf.tables_initializer()) | |
# Loading the save weights | |
model.load_weights('drive/My Drive/Colab Notebooks/Northout/model-04-0.84.hdf5') | |
# Predicting the similarity between the two input questions | |
predicts = model.predict([q1, q2], verbose=0) | |
predict_logits = predicts.argmax(axis=1) | |
print("----FINAL RESULT----") | |
if(predict_logits[0] == 1): | |
print("****Questions are Similar****") | |
else: | |
print("****Questions are not Similar****") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment