1
votes

I would like to restore the session from keras training model.

I tried to restore it through following process.

1,Create checkpoint file trained by keras

from keras.models import *
import keras.backend as K
from keras.applications.vgg16 import VGG16

model = VGG16_convolutions()
model.fit_generator(...)

with tf.Session() as ksess:
ksess = K.get_session()
saver.save(ksess, "./ksess.cpkt", global_step=0, latest_filename="checkpoint_state")

2,Restore the session of tensorflow

import tensorflow as tf

with tf.name_scope("block1_conv1"):
    block1_conv1_kernel = tf.Variable(initial_value=0, name="kernel")
    block1_conv1_bias = tf.Variable(initial_value=0, name="bias")
with tf.name_scope("block1_conv2"):
    block1_conv2_kernel = tf.Variable(initial_value=0, name="kernel")
    block1_conv2_bias = tf.Variable(initial_value=0, name="bias")
...

sess = tf.Session()
saver = tf.train.Saver()
saver = tf.train.import_meta_graph("ksess.ckpt-0.meta")
saver.restore(sess, "./ksess.ckpt")    

So, how can I restore session from keras training model?

Best regards.

1
Maybe, just maybe, you try googling your question. keras.io -> FAQ gives you all necessary information.Huang_d
Thank you for replying. Just you said, it's described the way to save the model of keras. But I can't restore the session using them.Shota
Google now points to this question as the first hit, so it might be worth answering anyway.Peter

1 Answers

0
votes

There already some answered questions similar to yours, I would recommend you to google them first. But if none of them works, maybe you can try this one and try to save your model and use it in another session.