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 29 30 31 32 33 34 35 36 37 38 39 40
| import tensorflow as tf
try:tf.Variable(initial_value=None, trainable=True, collections=None, validate_shape=True, caching_device=None, name=None, variable_def=None, dtype=None, expected_shape=None, import_scope=None) except:pass
a = tf.Variable(10,name='var1') b = tf.Variable([[11,12],[21.0,22.0]],name='var1') c = tf.Variable('田偉業',name='var1')
sess = tf.Session(); sess.run(tf.global_variables_initializer())
print(a.eval(session=sess))
print(b.eval(session=sess))
print(a.shape, a.dtype, a.trainable)
print(b.shape, b.dtype, b.trainable)
print(c.shape, c.dtype, c.trainable)
print(a.name,b.name,c.name)
|