loading pre trainned weights using variable name

code example:

    # load all variables that are equal in name
    graph_variables = [v.name for v in tf.trainable_variables()]
    variables_names = []
    for v in self.vgg_weights:
        if v.name in graph_variables:
            variables_names.append(v)


    # load all variables except for the last logic
    variables_names = []
    for v in tf.trainable_variables():
        if v.name == 'op_w_logits_b:0' or v.name == 'op_w_logits_w:0':
            break
        else:
            variables_names.append(v)

    # load store weights         
    tf.train.Saver(variables_names).restore(sess, self.ckpt_location + self.ckpt_name)
    
Manuel Cuevas

Manuel Cuevas

Hello, I'm Manuel Cuevas a Software Engineer with background in machine learning and artificial intelligence.

Recent post