Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
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)
Esempio n. 4
0
def trainable_variables(scope=None):
    return get_collection(_TRAINABLE_VARIABLES_KEY, scope)
Esempio n. 5
0
def global_variables():
    return get_collection(_GLOBAL_VARIABLES_KEY)
Esempio n. 6
0
def trainable_variables():
    return get_collection(_TRAINABLE_VARIABLES_KEY)
Esempio n. 7
0
def get_updates(key="training"):
    updates_list = get_collection(_SCAN_UPDATES_KEYS + "/" + key)

    return reduce(merge_updates, [OrderedDict()] + list(updates_list))