TensorFlow saver - 保存一个普通的 Python 变量 [英] TensorFlow saver - Saving an ordinary Python variable

查看:26
本文介绍了TensorFlow saver - 保存一个普通的 Python 变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 TensorFlow Saver 时,有没有办法同时保存一个普通的 Python 变量?

When using TensorFlow Saver, is there a way to save an ordinary Python variable as well?

如果不是,当某些 Python 变量有助于保存时,最佳解决方案是什么.

If not, what is the best solution when certain Python vars are helpful to save.

推荐答案

您可以使用 pickle 保存/恢复 Python 变量.

You can save/restore python variables with pickle.

import pickle

f = open('store.pckl', 'wb')
pickle.dump(your_var, f)
f.close()

f = open('store.pckl', 'rb')
your_var = pickle.load(f)
f.close()

这篇关于TensorFlow saver - 保存一个普通的 Python 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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