Let's say I have two tensorflow models(A and B) with exactly the same graph but different weights in each layer. I want to merge layers conv1, conv2, conv3 from A and layers conv4, conv5, conv6 from B into one model C. Model C has the same structure as A and B, but different weights. I know how to separetly load layers from each model using the following code and made two seprate models each containing only conv1,2,3 or 4,5,6. But I don't know how to build a model C with conv1,2,3,4,5,6.
exclude1=['conv1',...]
exclude2=['conv4',...]
variables_to_restore1=slim.get_variables_to_restore(exclude=exclude1)
variables_to_restore2=slim.get_variables_to_restore(exclude=exclude2)
saver1 = tf.train.Saver(variables_to_restore1)
saver2 = tf.train.Saver(variables_to_restore2)
saver1.restore(sess,args.model)
saver2.restore(sess,args.model)
saver1.save(sess, "Model/convlayers1.ckpt")
saver2.save(sess, "Model/convlayers2.ckpt")
I've been learning tensorflow for a few months but has not seen something like this. Thank you very much!