- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我刚刚将本地安装的 Tensorflow 更新为 0.11rc2,我收到一条消息说我应该向我的保护程序添加一个参数以使其保存在版本 2 中。我更新了它,现在我无法加载保存在版本 2 中的模型这种格式。当我运行我的模型时,它会在每个纪元后保存。保存时,它用于保存名为 translate.ckpt-3916
和 translate.ckpt-3916.meta
的文件。现在我得到三个文件而不是两个,分别命名为 translate.ckpt-3916.index
、translate.ckpt-3916.meta
和 translate.ckpt-3916。 data-000000-of-000001
。
要加载数据,我使用以下代码:
ckpt = tf.train.get_checkpoint_state(FLAGS.train_dir)
if ckpt and tf.gfile.Exists(ckpt.model_checkpoint_path):
print("Reading model parameters from %s" % ckpt.model_checkpoint_path)
model.saver.restore(session, ckpt.model_checkpoint_path)
else:
print("Created model with fresh parameters.")
session.run(tf.initialize_all_variables())
return model
model
是一个模型对象,它已经用我的程序的标准超参数初始化了。这对 saver v1 没有问题。 ckpt.model_checkpoint_path
评估为 translate.ckpt-3916
的路径,无论版本如何,因此如果检查点是使用 v2 保存的,则找不到文件。
该目录中的 checkpoint
文件的内容(当使用任一版本保存时)是:
model_checkpoint_path: "translate.ckpt-3916"
all_model_checkpoint_paths: "translate.ckpt-3916"
saver v2有没有新的加载数据的方法?否则,我该如何加载我的检查点?
编辑:将 if ckpt and tf.gfile.Exists(ckpt.model_checkpoint_path):
行更改为 if ckpt and ckpt.model_checkpoint_path:
,如 this question 所示。似乎更进一步但随后抛出以下错误:
InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [84] rhs shape= [98]
[[Node: save/Assign_54 = Assign[T=DT_FLOAT, _class=["loc:@NLC/Logistic/Linear/Bias"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](NLC/Logistic/Linear/Bias, save/RestoreV2_54)]]
最佳答案
我在编辑中发布的方法实际上是使它起作用的正确方法。我得到的错误是因为数据在我创建检查点和我尝试加载它之间发生了变化。
只是为了使其可见,通过将行 if ckpt and tf.gfile.Exists(ckpt.model_checkpoint_path):
更改为 if 来完成从上面代码中的 V2 检查点加载ckpt 和 ckpt.model_checkpoint_path:
关于python - 使用 Saver v2 加载模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40469553/
重要说明:我只是在笔记本环境中运行这一部分,图形定义。我还没有运行实际的 session 。 运行这段代码时: with graph.as_default(): #took out " , tf.de
将训练好的模型参数保存起来,以便以后进行验证或测试,这是我们经常要做的事情。tf里面提供模型保存的是tf.train.Saver()模块。 模型保存,先要创建一个Saver对象:如
我尝试运行一个简单的程序来将 Tensorflow session 保存到磁盘上作为“spikes.cpkt”。虽然在交互式程序中,系统输出显示我已成功创建该文件,但我在文件系统中找不到该文件。 我使
我有一个带有Autoencoder的docker容器,可以通过Flask-Server启动它。所有脚本都被复制到Docker的/ root中,并且还可以访问共享卷/ data,如下所示: /数据 -/
我需要将我的 iPad 应用程序完全按照它在设备上运行的方式镜像到外部屏幕上,但在一段时间不事件后,外部屏幕应显示静态图像,直到设备再次接收触摸输入。我今天阅读了很多关于在 iOS 中处理多个屏幕的内
我正在尝试在我的 Angular 2 应用程序中实现下载按钮。 我用过这些教程: http://alferov.github.io/angular-file-saver/ https://coryry
根据有关此 API 的文档和大量 SO 帖子,必须使用 创建保护程序对象 saver = tf.train.Saver(...variables...) 我想知道是否有任何方法可以自动填充(...va
Android 7.0 Nougat 添加了 Data Saver 功能,允许用户限制某些应用程序(包括推送通知)的后台数据。当 Data Saver 开启时,只有在 中找到的列表中的应用程序 Set
我正在为 Android 开发一个音乐流媒体应用。 在这个应用程序中,我有一个 Service 负责播放来自 HTTP 服务器的音频。在播放之前,我确保 startForeground() 并获取部分
var MyFiles = []; if (val == "Address") { MyFiles.push({ 'file': 'http://-
我发现如果要保存某个图的所有变量,必须在图的最后定义tf.train.Saver,否则saver无法获取所有变量变量。 这是我的测试代码: def how_saver_work(): g =
是否可以通过 drop-in saver 将 localhost 文件上传到 dropbox?( https://www.dropbox.com/developers/dropins/saver )
我有一个训练好的模型,使用tf.train.Saver保存,生成4个相关文件 检查点 model_iter-315000.data-00000-of-00001 model_iter-315000.i
我刚刚将本地安装的 Tensorflow 更新为 0.11rc2,我收到一条消息说我应该向我的保护程序添加一个参数以使其保存在版本 2 中。我更新了它,现在我无法加载保存在版本 2 中的模型这种格式。
关于模型保存的一点心得 ? 1
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 3 年前。 Improve th
我创建了一些按钮,并且单击按钮 url 和文件名发送到动态数组,当我单击 dropbox saver 按钮时,我希望 saver 函数使用该动态数组将文件发送到 dropbox。我当前的代码出现此错误
我想知道在每次训练后使用 tf.train.Saver() 保存我的模型时到底保存了什么。与我习惯使用 Keras 模型的文件相比,该文件似乎有点大。现在我的 RNN 在每次保存时占用 900 MB。
我们可以保存一个检查点 saver = tf.train.Saver() saver.save(sess, FLAGS.train_dir, global_step=step) 然后,稍后,我可以恢复
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 3 年前。 Improve th
我是一名优秀的程序员,十分优秀!