更新时间:2023-09-21 08:04:40
在Dan Cornilescu提出一些技巧并进行深入研究后,我发现Tensorflow使用名为ParseFromString
的函数构建了MetaGraphDef
,所以这就是我的最终结果在做:
After some tips from Dan Cornilescu and digging into it I found that Tensorflow builds the MetaGraphDef
with a function called ParseFromString
, so here's what I ended up doing:
from google.cloud import storage
from tensorflow import MetaGraphDef
client = storage.Client()
bucket = client.get_bucket(Config.MODEL_BUCKET)
blob = bucket.get_blob('model.ckpt.meta')
model_graph = blob.download_as_string()
mgd = MetaGraphDef()
mgd.ParseFromString(model_graph)
with tf.Session() as sess:
saver = tf.train.import_meta_graph(mgd)