Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import tensorflow as tf
  2. import numpy as np
  3.  
  4. X_DIM=2048
  5. Y_DIM=128
  6.  
  7. tf.set_random_seed(123)
  8.  
  9. varz = tf.get_variable("v", [X_DIM, Y_DIM],
  10. dtype=tf.float32,
  11. initializer=tf.random_normal_initializer(seed=123))
  12.  
  13.  
  14. with tf.Session() as sess:
  15. sess.run(tf.global_variables_initializer())
  16.  
  17. v1 = sess.run(varz)
  18.  
  19. with tf.Session() as sess:
  20. sess.run(tf.global_variables_initializer())
  21. v2 = sess.run(varz)
  22.  
  23. print(np.max(np.absolute(v2-v1)))
  24. assert(np.allclose(v1, v2, rtol=1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement