如何在检查点中列出某些变量? [英] How do I list certain variables in the checkpoint?
问题描述
我正在使用自动编码器.我的检查点包含网络的完整状态(即编码器,解码器,优化器等).我想鬼混编码.因此,在评估模式下,我只需要网络的解码器部分.
I am working with autoencoders. My checkpoint contains the complete state of the network (i.e. the encoder, decoder, optimizer, etc). I want to fool around with the encodings. Therefore, I would only need the decoder part of the network in my evaluation mode.
如何仅从现有检查点读取一些特定变量,以便可以在其他模型中重用它们的值?
How can I read only a few specific variables from the existing checkpoint, so that I can reuse their values in another model?
推荐答案
There's list_variables
method in checkpoint_utils.py which lets you see all saved variables.
但是,对于您的用例,使用Saver
还原可能会更容易.如果在保存检查点时知道变量的名称,则可以创建一个新的保护程序,并告诉它将这些名称初始化为新的Variable
对象(可能使用不同的名称).在CIFAR示例中使用它来选择恢复在Howto中选择要保存和还原的变量
However, for your use-case, it may be easier to restore with a Saver
. If you know the names of the variables when you saved the checkpoint, you can create a new saver, and tell it to initialize those names into new Variable
objects (possibly with different names). This is used in CIFAR example to select a restore a subset of variables. See Choosing which Variables to Save and Restore in the Howto
这篇关于如何在检查点中列出某些变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!