1
我想有這樣的事情:如何在tensorflow中設置默認變量集合?
with tf.variable_scope("yes", default_collection=["A", "B"]):
...
有什麼我能做些什麼呢?
我想有這樣的事情:如何在tensorflow中設置默認變量集合?
with tf.variable_scope("yes", default_collection=["A", "B"]):
...
有什麼我能做些什麼呢?
這是不是很方便結合起來,但你可以使用tf.variable_scope
定義custom_getter
:
def make_local_getter(getter, *args, **kwargs):
if kwargs['collections'] is None:
kwargs['collections'] = []
kwargs['collections'] += [tf.GraphKeys.LOCAL_VARIABLES]
return getter(*args, **kwargs)
with tf.variable_scope(scope, custom_getter=make_local_getter):
tf.get_variable(...)