Created
August 18, 2017 14:27
-
-
Save ahaider3/82a8eae7a378a729d2420968acfe4bfd to your computer and use it in GitHub Desktop.
Tensorflow random initialization
This file contains hidden or 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 | |
import numpy as np | |
X_DIM=2048 | |
Y_DIM=128 | |
tf.set_random_seed(123) | |
varz = tf.get_variable("v", [X_DIM, Y_DIM], | |
dtype=tf.float32, | |
initializer=tf.random_normal_initializer(seed=123)) | |
with tf.Session() as sess: | |
sess.run(tf.global_variables_initializer()) | |
v1 = sess.run(varz) | |
with tf.Session() as sess: | |
sess.run(tf.global_variables_initializer()) | |
v2 = sess.run(varz) | |
print(np.max(np.absolute(v2-v1))) | |
assert(np.allclose(v1, v2, rtol=1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment