简体   繁体   English

如何在Tf SLIM中加载保存的检查点

[英]how to load saved checkpoint in Tf SLIM

I am using TF-slim to train my own dataset. 我正在使用TF-slim训练自己的数据集。 According to the tutorial, in the finetune_inception_v1_on_flowers.sh, I set the checkpoint path as ./inception_resnet_v2.ckpt, and get lots of new checkpoints in another file folder, and the latest files are model.ckpt-332331.data-00000-of-00001,model.ckpt-332331.index, model.ckpt-332331.meta. 根据该教程,在finetune_inception_v1_on_flowers.sh中,我将检查点路径设置为./inception_resnet_v2.ckpt,并在另一个文件夹中获得许多新的检查点,最新文件为model.ckpt-332331.data-00000-of -00001,model.ckpt-332331.index,model.ckpt-332331.meta。

now I want to change the learning rate to fine turing the latest check point, but I don't know how to load them in the finetune_inception_v1_on_flowers.sh because there are 3 files instead of one. 现在,我想将学习率更改为精确到最新的检查点,但是我不知道如何将它们加载到finetune_inception_v1_on_flowers.sh中,因为有3个文件而不是1个。

firstly, I tried to copy the  model.ckpt-332331.data-00000-of-00001 and set the  checkpoint path as ./model.ckpt-332331.data-00000-of-00001 ,but there is the error:

NotFoundError (see above for traceback): Key InceptionResnetV2/AuxLogits/Conv2d_1b_1x1/weights/Adam not found in checkpoint [[Node: save/RestoreV2_4 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2_4/tensor_names, save/RestoreV2_4/shape_and_slices)]] NotFoundError(请参阅上面的回溯):密钥InceptionResnetV2 / AuxLogits / Conv2d_1b_1x1 / weights / Adam在检查点[[Node:save / RestoreV2_4 = RestoreV2 [dtypes = [DT_FLOAT],_device =“ / job:localhost / replica:0 /任务:0 / cpu:0“](_ recv_save / Const_0,保存/恢复V2_4 /张量名称,保存/恢复V2_4 / shape_and_slices)]]

secondly, I removed the files from log directory ,then the error is : 其次,我从日志目录中删除了文件,那么错误是:

DataLossError (see above for traceback): Unable to open table file /media/re/7A308F7E308F405D/xsj/checkpoints/model.ckpt-332331.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator? DataLossError(请参阅上面的回溯):无法打开表文件/media/re/7A308F7E308F405D/xsj/checkpoints/model.ckpt-332331.data-00000-of-00001:数据丢失:不是sstable(错误的魔术数字):也许您的文件采用其他文件格式,并且需要使用其他还原操作符? [[Node: save/RestoreV2_5 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2_5/tensor_names, save/RestoreV2_5/shape_and_slices)]] [[节点:保存/还原V2_5 = RestoreV2 [dtypes = [DT_FLOAT],_ device =“ / job:localhost /副本0 /任务:0 / cpu:0”]] __ recv_save / Const_0,保存/还原V2_5 / tensor_names,保存/ RestoreV2_5 / shape_and_slices)]]

Can anyone help me to solve the problem? 谁能帮助我解决问题? Thank you very much! 非常感谢你!

As mentioned in https://www.tensorflow.org/guide/saved_model https://www.tensorflow.org/guide/saved_model中所述

There is not a physical file called /tmp/model.ckpt. 没有一个名为/tmp/model.ckpt的物理文件。 It is the prefix of filenames created for the checkpoint. 它是为检查点创建的文件名的前缀。 Users only interact with the prefix instead of physical checkpoint files. 用户仅与前缀交互,而不与物理检查点文件交互。

So you just need to set checkpoint path as ./model.ckpt-332331 因此,您只需要将检查点路径设置为./model.ckpt-332331

进行微调时,只需指定目录($ CHECKPOINT_PATH)而不是任何特定文件,它将自动获取路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 Colaboratory 中保存的检查点加载 TensorFlow Keras model? - How to load TensorFlow Keras model from a saved checkpoint in Colaboratory? 我如何在每个时期保存检查点并加载随机保存的检查点以继续训练 - How I can save checkpoint every epoch and load an random saved checkpoint to continue training 如何使用tf.train.Checkpoint在Tensorflow 2.0中保存和加载选定变量以及所有变量? - How to save and load selected and all variables in tensorflow 2.0 using tf.train.Checkpoint? 使用TF-slim评估重新调整的Inception-v3模型时,“在检查点中找不到张量” - “tensor not found in the checkpoint” when evaluating the re-tuned inception-v3 model using TF-slim tf.train.Saver-在不同的机器上加载最新的检查点 - tf.train.Saver - Load latest checkpoint on different machine 如何限制TF Slim中的GPU内存使用? - How to limit GPU memory use in TF Slim? 如何从检查点加载图层 - How to load a layer from checkpoint 加载已保存的检查点并预测不会产生与训练相同的结果 - Load saved checkpoint and predict not producing same results as in training 如何使用checkpoint的tf.estimator.Estimator进行预测? - How to make predictions with tf.estimator.Estimator from checkpoint? 如何使用tf.train.Checkpoint保存很多变量 - how to save a lot of variables with tf.train.Checkpoint
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM