pretrain model

1 加载预训练模型注意:

I'm not sure which file you are trying to load. I recently tried loading a pretrained model with train_tripletloss.py and worked out fine. Then I used

--pretrained_model ~/models/20170214-092102/model-20170214-092102.ckpt-80000

But it should be noted that there is no file named model-20170214-092102.ckpt-80000 in the 20170214-092102 directory, so Tensorflow adds .data-00000-of-00001 before restoring. These are the files in the directory:

-rwxrwxrwx 1 root root 96689276 feb 14 18:49 model-20170214-092102.ckpt-80000.data-00000-of-00001

-rwxrwxrwx 1 root root    22478 feb 14 18:49 model-20170214-092102.ckpt-80000.index

-rwxrwxrwx 1 root root 19991968 feb 14 09:29 model-20170214-092102.meta

2 Finetune模型(需要修改):

I had the same problems, and solved by changing the code

" saver = tf.train.Saver(tf.trainable_variables(), max_to_keep=3) "

as follows:

all_vars = tf.trainable_variables()

var_to_restore = [v for v in all_vars if not v.name.startswith('Logits')]

saver = tf.train.Saver(var_to_restore)

which gets a list of all of the variables in the model and filter out the variables of the last layer.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容