TensorFlow函数(四)tf.trainable_variable() 和 tf.all_variable()

tf.trainable_variable()

此函数返回的是需要训练的变量列表

tf.all_variable()

此函数返回的是所有变量列表

1 v = tf.Variable(tf.constant(0.0, shape=[1], dtype=tf.float32), name='v')
2 v1 = tf.Variable(tf.constant(5, shape=[1], dtype=tf.float32), name='v1')
3 
4 global_step = tf.Variable(tf.constant(5, shape=[1], dtype=tf.float32), name='global_step', trainable=False)
5 ema = tf.train.ExponentialMovingAverage(0.99, global_step)

是不是训练变量主要根据 tf.Variable() 和 tf.get_variable() 中参数 trainable 设定的

原文地址:https://www.cnblogs.com/reaptomorrow-flydream/p/9488013.html