(tvars, init_checkpoint)
return assignment_map, initialized_variable_names, new_variable_names, unused_variable_names
Compute the union of the current variables and checkpoint variables.
Compute the union of the current variables and checkpoint variables.
Compute the union of the current variables and checkpoint variables .
def get_assigment_map_from_checkpoint(tvars, init_checkpoint):
    """Compute the union of the current variables and checkpoint variables."""
    initialized_variable_names = {}
    new_variable_names = set()
    unused_variable_names = set()

    name_to_variable = collections.OrderedDict()
    for var in tvars:
        name = var.name
        m = re.match("^(.*):\\d+$", name)
        if m is not None:
            name = m.group(1)
        name_to_variable[name] = var

    init_vars = tf.train.list_variables(init_checkpoint)

    assignment_map = collections.OrderedDict()
    for x in init_vars:
        (name, var) = (x[0], x[1])
        if name not in name_to_variable:
            if 'adam' not in name:
                unused_variable_names.add(name)
            continue
        # assignment_map[name] = name
        assignment_map[name] = name_to_variable[name]
        initialized_variable_names[name] = 1
        initialized_variable_names[name + ":0"] = 1

    for name in name_to_variable:
        if name not in initialized_variable_names:
            new_variable_names.add(name)
    return assignment_map, initialized_variable_names, new_variable_names, unused_variable_names
def get_assigment_map_from_checkpoint ( tvars , init_checkpoint ) : initialized_variable_names = { } new_variable_names = set ( ) unused_variable_names = set ( ) name_to_variable = collections . OrderedDict ( ) for var in tvars : name = var . name m = re . match ( "^(.*):\\d+$" , name ) if m is not None : name = m . group ( 1 ) name_to_variable [ name ] = var init_vars = tf . train . list_variables ( init_checkpoint ) assignment_map = collections . OrderedDict ( ) for x in init_vars : ( name , var ) = ( x [ 0 ] , x [ 1 ] ) if name not in name_to_variable : if 'adam' not in name : unused_variable_names . add ( name ) continue # assignment_map[name] = name assignment_map [ name ] = name_to_variable [ name ] initialized_variable_names [ name ] = 1 initialized_variable_names [ name + ":0" ] = 1 for name in name_to_variable : if name not in initialized_variable_names : new_variable_names . add ( name ) return assignment_map , initialized_variable_names , new_variable_names , unused_variable_names