2017-03-02 74 views

回答

4

假设您已经在范围InceptionV1范围内有Google的InceptionNet模型,并且您想要加载它,但要重新训练的范围InceptionRetrained的最后一层除外。

假设你已经开始重新训练的最后一层,你通过saver2.save(session, 'last_layer.ckpt')创建last_layer.ckpt文件,这里是如何从检查点恢复净。

saver1 = tf.train.Saver(var_list=tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope='InceptionV1')) 
saver1.restore(session, 'inception_model_from_google.ckpt') 

saver2 = tf.train.Saver(var_list=tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope='InceptionRetrained')) 
saver2.restore(session, 'last_layer.ckpt') 

如果你再培训只剩下最后一层,不要忘记通过调用优化与var_list参数禁用梯度向上的网络(节省时间)的传播。

tf.train.Optimizer(0.0001).minimize(
      loss, var_list=tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope='Inceptionretrained'))