1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| import tensorflow as tf
try: tf.get_variable(name, shape=None,dtype=None, initializer=None, regularizer=None, trainable=True, collections=None, caching_device=None, partitioner=None, validate_shape=True, use_resource=None, custom_getter=None) except: pass
a =tf.get_variable('var1',initializer=[1,2,3]) b =tf.get_variable('var2',initializer=[1])
SESS = tf.Session(); SESS.run(tf.global_variables_initializer())
print(a.eval(session=SESS),a.name, b.eval(session=SESS),b.name, sep='\n')
|