请教如何导入pre-trained模型
tensorflow吧
全部回复
仅看楼主
level 1
Galois域 楼主
我下载了一些resnet_v2的模型,文件后缀名是ckpt,里面包含了网络和weight都全了。
请问如何加载?
#!/usr/bin/env python3
import tensorflow as tf
from tensorflow.python.platform import gfile
import numpy as np
import os
os.environ["CUDA_VISIBLE_DEVICES"] = '2' #use GPU with ID=0
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.7 # maximun alloc gpu20% of MEM
config.gpu_options.allow_growth = True #allocate dynamically
x = tf.placeholder(tf.float32, shape=(224,224));
with tf.Session(config = config) as sess:
path_ckpt = "resnet_v2_50.ckpt"
output_graph_def = tf.GraphDef()
with gfile.FastGFile(path_ckpt, "rb") as f
#这里就是显示RuntimeWarning: Unexpected end-group tag: Not all data was converted
output_graph_def.ParseFromString(f.read())
_ = tf.import_graph_def(output_graph_def, name="")
for i,n in enumerate(output_graph_def.node):
print("Name of the node - %s" % n.name)
以上代码还是没有加载进来。多谢赐教
2019年04月12日 02点04分 1
level 1
你好聪明。可以装疯卖傻看不懂帖子;可以颠倒黑白把药物下架说成好事。
2020年03月29日 01点03分 2
回帖居然回到这里来了,I服了you。今天才看到。药物下架代表我们面对我们之前的问题,我们可以找到更好的药物来替代我们之前的药物,这怎么就成了坏事?不仅是药物,我们所有的理论都是这样一步步的来的,有什么问题吗?
2020年04月03日 03点04分
1