from LinearRegression import my_model from mnist import model x = tf.placeholder("float", [None, 784]) x1 = tf.placeholder(tf.float32) sess = tf.Session() # restore trained data with tf.variable_scope("regression"): y1, variables = model.regression(x) saver = tf.train.Saver(variables) saver.restore(sess, "mnist/data/regression.ckpt") with tf.variable_scope("convolutional"): keep_prob = tf.placeholder("float") y2, variables = model.convolutional(x, keep_prob) saver = tf.train.Saver(variables) saver.restore(sess, "mnist/data/convolutional.ckpt") with tf.variable_scope("my_model"): y3, variables = my_model.regr(x1) saver = tf.train.Saver(variables) saver.restore(sess, "LinearRegression/data/linear_regression.ckpt") decision_tree = joblib.load('DecisionTree/data/parsing_tree.pkl') knn = joblib.load('KNN/data/knn.pkl') svm = joblib.load('SVM/data/svm.pkl') gaussian = joblib.load('Gaussian/data/gaussian.pkl') def regression(input):
from mnist import model X1 = tf.placeholder("float", [None, 784]) X2 = tf.placeholder(tf.float32, [None, 28, 28, 1]) sess = tf.Session() # restore trained data with tf.variable_scope("regression"): Y1, variables = model.regression(X1) saver = tf.train.Saver(variables) saver.restore(sess, "mnist/data/regression.ckpt") print("Regression model restored.") with tf.variable_scope("convolutional"): pkeep = tf.placeholder(tf.float32) Y2, Ylogits, variables = model.convolutional(X2, pkeep) saver = tf.train.Saver(variables) saver.restore(sess, "mnist/data/convolutional.ckpt") print("Convolutional model restored.") def regression(input): return sess.run(Y1, feed_dict={X1: input}).flatten().tolist() def convolutional(input): return sess.run(Y2, feed_dict={X2: input, pkeep: 1.0}).flatten().tolist() # webapp app = Flask(__name__)
from mnist import model x = tf.placeholder("float", [None, 784]) sess = tf.Session() # restore trained data with tf.variable_scope("regression"): y1, variables = model.regression(x) saver = tf.train.Saver(variables) saver.restore(sess, "mnist/data/regression.ckpt") with tf.variable_scope("convolutional"): keep_prob = tf.placeholder("float") y2, variables = model.convolutional(x, keep_prob) saver = tf.train.Saver(variables) saver.restore(sess, "mnist/data/convolutional.ckpt") def regression(input): return sess.run(y1, feed_dict={x: input}).flatten().tolist() def convolutional(input): return sess.run(y2, feed_dict={x: input, keep_prob: 1.0}).flatten().tolist() # webapp app = Flask(__name__)
db = DataStore() x = tf.placeholder("float", [None, 784]) sess = tf.Session() # restore trained data with tf.variable_scope("perceptron"): y_percep, perceptron_variables = model.multilayer_perceptron(x) with tf.variable_scope("regression"): y_reg, regression_variables = model.regression(x) with tf.variable_scope("convolutional"): keep_prob = tf.placeholder(tf.float32) y_conv, conv_variables = model.convolutional(x, keep_prob) with tf.variable_scope("rnn"): y_rnn, _ = model.rnn_network(x) rnn_variables = tf.get_collection(tf.GraphKeys.VARIABLES, scope='rnn') saver = tf.train.Saver(conv_variables + perceptron_variables + regression_variables + rnn_variables) saver.restore(sess, "mnist/data/mnist.ckpt") def regression(input): return sess.run(tf.nn.softmax(y_reg), feed_dict={ x: input }).flatten().tolist()
x = tf.placeholder("float", [None, 784]) sess = tf.Session() # restore trained data with tf.variable_scope("regression"): logits1, variables1 = model.regression(x) y1 = tf.nn.softmax(logits1) saver = tf.train.Saver(variables1) saver.restore(sess, "mnist/data/regression.ckpt") with tf.variable_scope("convolutional"): keep_prob = tf.placeholder("float") logits2, variables2 = model.convolutional(x, keep_prob) y2 = tf.nn.softmax(logits2) saver = tf.train.Saver(variables2) saver.restore(sess, "mnist/data/convolutional.ckpt") def regression(input): return sess.run(y1, feed_dict={x: input}).flatten().tolist() def convolutional(input): return sess.run(y2, feed_dict={x: input, keep_prob: 1.0}).flatten().tolist() # webapp app = Flask(__name__)