I am training a model in tensorflow and I am doing checkpoints for my model. I the Checkpoints directory, I have four files namely,
checkpointmodel.cpkt-0.data-00000-of-00001model.cpkt-0.indexmodel.cpkt-0.metaNow I want to extract the weights values for each layer in my graph, how can I do that?
I tried this:
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')
But I am getting the following error:
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?
You are restoring in a wrong way
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')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With