Last active
April 29, 2019 13:52
-
-
Save mortendahl/a10de0d77eda607bb6ea4410f4b70d07 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 tensorflow as tf | |
def provide_weights():""" Load from disk """ | |
def provide_input(): """ Pre-process """ | |
def receive_output(logits): return tf.print(tf.argmax(logits)) | |
# get model weights | |
w0, b0, w1, b1, w2, b2 = provide_weights() | |
# get prediction input | |
x = provide_input() | |
# compute prediction | |
layer0 = tf.nn.relu((tf.matmul(x, w0) + b0)) | |
layer1 = tf.nn.relu((tf.matmul(layer0, w1) + b1)) | |
logits = tf.matmul(layer2, w2) + b2 | |
# process result of prediction | |
prediction_op = receive_output(logits) | |
# run graph execution in a tf.Session | |
with tf.Session() as sess: | |
sess.run(prediction_op) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment