如何在检查点中列出某些变量? [英] How do I list certain variables in the checkpoint?

查看:105
本文介绍了如何在检查点中列出某些变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用自动编码器.我的检查点包含网络的完整状态(即编码器,解码器,优化器等).我想鬼混编码.因此,在评估模式下,我只需要网络的解码器部分.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆