如何从.ckpt文件加载图形

时间:2019-01-30 06:41:39

标签: python tensorflow deep-learning pre-trained-model

在使用此代码训练Inception v3模型时,我曾使用.pb文件加载图形

with tf.Graph().as_default() as graph:
    model_path = os.path.join(MODEL_DIR, model_info['model_file_name'])
    print('Model path: ', model_path)
    with gfile.FastGFile(model_path, 'rb') as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
        bottleneck_tensor, resized_input_tensor = (tf.import_graph_def(graph_def, name='', return_elements=[model_info['bottleneck_tensor_name'], model_info['resized_input_tensor_name'],]))

其中model_info是

的字典
data_url = 'http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz'    
bottleneck_tensor_name = 'pool_3/_reshape:0'
bottleneck_tensor_size = 2048
input_width = 299
input_height = 299
input_depth = 3
resized_input_tensor_name = 'Mul:0'
model_file_name = 'classify_image_graph_def.pb'
input_mean = 128
input_std = 128

现在我要使用Inception v4,它将保存在.ckpt文件中。如何使用.ckpt文件加载图形以适合此格式

0 个答案:

没有答案