def _get_default_variable_store(): store = get_collection(_VARSTORE_KEY) if store: return store[0] # create a new store store = variable_store() add_to_collection(_VARSTORE_KEY, store) return store
def get_variable_scope(): # get_collection returns a list scope = get_collection(_VARSCOPE_KEY) if scope: # only 1 element in the list return scope[0] # create a new scope scope = var_scope(False) add_to_collection(_VARSCOPE_KEY, scope) return scope
def get_regularization_loss(scopes): if scopes is None: scopes = [None] if not isinstance(scopes, (tuple, list)): raise ValueError("parameter: scopes should be either a tuple or list") print scopes loss_list = [ loss for scope in scopes for loss in get_collection(_REGULARIZATION_LOSSES_KEYS, scope) ] loss_list = list(set(loss_list)) if not loss_list: return None return reduce(theano.tensor.add, loss_list)
def trainable_variables(scope=None): return get_collection(_TRAINABLE_VARIABLES_KEY, scope)
def global_variables(): return get_collection(_GLOBAL_VARIABLES_KEY)
def trainable_variables(): return get_collection(_TRAINABLE_VARIABLES_KEY)
def get_updates(key="training"): updates_list = get_collection(_SCAN_UPDATES_KEYS + "/" + key) return reduce(merge_updates, [OrderedDict()] + list(updates_list))