我在tensorflow中训练模型,我正在为我的模型做检查点。我是Checkpoints
目录,我有四个文件,
checkpoint
model.cpkt-0.data-00000-of-00001
model.cpkt-0.index
model.cpkt-0.meta
现在我想提取图表中每一层的权重值,我该怎么做?
我试过了:
import tensorflow as tf
sess = tf.InteractiveSession()
saver = tf.train.import_meta_graph('model.cpkt-0.meta')
w = saver.restore(sess, 'model.cpkt-0.data-00000-of-00001')
但是我收到以下错误:
Unable to open table file ./model.cpkt-0.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?
答案 0 :(得分:4)
你正在以错误的方式恢复
saver.restore(sess, 'model.cpkt-0')
# get the graph
g = tf.get_default_graph()
w1 = g.get_tensor_by_name('some_variable_name as per your definition in the model')