猿问

将多个 MetaGraphDefs 导入单个图形并恢复变量

与TensorFlow类似的问题:Restoring Multiple Graphs but using the tf.train.import_meta_graph() interface。


我的代码:


    with self.graph.as_default(), tf.device(device):

        with tf.Session(graph=self.graph, config=self.tf_config) as sess:


            # Add inherited graphs to CenterNet's graph.

            self.mm_saver = tf.train.import_meta_graph(self.maskmaker.model_ckpt + ".meta")

            self.dv_saver = tf.train.import_meta_graph(self.deepvar.model_ckpt + ".meta")


            # First saver can restore

            self.mm_saver.restore(sess, self.maskmaker.model_ckpt)

            # Second saver raises an exception

            self.dv_saver.restore(sess, self.deepvar.model_ckpt)

异常(没有回溯,这是非常非常长的)。


NotFoundError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Key classifier/bias not found in checkpoint

     [[node save/RestoreV2 (defined at /home/markemus/dev/IHC/ihc/neuralnets.py:936)  = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT32], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]

看起来 dv_saver 正在尝试恢复图形上的所有变量,而不仅仅是它自己的变量。失败的关键,“分类器/偏差”,最初是 mm 图表的一部分。


我如何限制它恢复自己的密钥?


杨魅力
浏览 206回答 1
1回答
随时随地看视频慕课网APP

相关分类

Python
我要回答