-3

I've created a CNN which has 2 conv layers followed by FC layer and output layer (2 nodes only) then I saved the parameters using saver.save (sess,path), now I want to load the pre-trained weights and freeze all layers then insert another FC2 layer after FC1 and before output layer.

TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

0

i found a useful soluation

convWeights = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES,scope="THE SCOPE OR VARIABLE OR LAYER NAME")                               
convDict = dict([(var.op.name, var) for var in convWeights])
saver = tf.train.Saver(convDict)

with tf.Session() as sess:
    sess.run(init);
    saver.restore(sess, "MODEL.ckpt")