tf.AUTO_REUSE

通过get_variable("v")函数获取变量时,如果tf.variable_scope的reuse参数是True, 如果v是已经被创建过了就直接返回,但是如果没有创建会报错。如果设置成False,变量v如果没有被创建过就直接创建,如果创建过就报错。

AUTO_REUSE的好处就是实现:

如果创建过就返回,没有创建过就创建一个新的变量返回

AUTO_REUSE.__doc__ = """
When passed in as the value for the `reuse` flag, AUTO_REUSE indicates that
get_variable() should create the requested variable if it doesn't exist or, if
it does exist, simply return it.
"""

 

 

你可能感兴趣的:(Tensorflow)