Skip to content

Instantly share code, notes, and snippets.

@ryaninhust
Created May 17, 2020 12:02
Show Gist options
  • Save ryaninhust/66963239346def231d8fd349f7b1b1b0 to your computer and use it in GitHub Desktop.
Save ryaninhust/66963239346def231d8fd349f7b1b1b0 to your computer and use it in GitHub Desktop.
import tensorflow as tf
import numpy as np
vocabulary_size = 10
embeddings = tf.placeholder(tf.float32, shape=[vocabulary_size])
a = embeddings
c = a*2
with tf.Session() as sess:
sess.run(tf.initialize_all_variables())
#1
a_,c_ = sess.run([a, c], feed_dict={embeddings: np.random.rand(10)})
print(c_/a_)
#2
a_ = sess.run(a, feed_dict={embeddings: np.random.rand(10)})
c_ = sess.run(c, feed_dict={a: a_})
print(c_/a_)
#3
a_ = sess.run(a, feed_dict={embeddings: np.random.rand(10)})
c_ = sess.run(c, feed_dict={embeddings: np.random.rand(10)})
print(c_/a_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment