Skip to content

Instantly share code, notes, and snippets.

@miquelbeltran
Last active August 31, 2018 08:25
Show Gist options
  • Select an option

  • Save miquelbeltran/b9f4b17b8380aaa36c985c1b553494d5 to your computer and use it in GitHub Desktop.

Select an option

Save miquelbeltran/b9f4b17b8380aaa36c985c1b553494d5 to your computer and use it in GitHub Desktop.
import tensorflow as tf
inp = tf.placeholder(name="inp", dtype=tf.float32, shape=(1, 1))
w = tf.Variable(tf.zeros([1, 1], tf.float32), dtype=tf.float32, name="w")
y = tf.matmul(w, inp)
out = tf.identity(y, name="out")
init_op = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init_op)
# After Init var, change the value to 2
assignment = w.assign([[2]])
sess.run(assignment)
output = sess.run(out, feed_dict={inp: [[1]]})
print(output)
# This throws an error!
tflite_model = tf.contrib.lite.toco_convert(sess.graph_def, [inp], [out])
open("mat_mul.tflite", "wb").write(tflite_model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment