1

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.

Shota
  • 11
  • 2
  • 1
    Maybe, just maybe, you try googling your question. keras.io -> FAQ gives you all necessary information. – Huang_d Aug 07 '18 at 07:42
  • 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 Aug 07 '18 at 07:50
  • Google now points to this question as the first hit, so it might be worth answering anyway. – Peter Oct 29 '20 at 11:58

1 Answers1

0

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.

ozata
  • 542
  • 1
  • 5
  • 16
  • Thank you for your reply. I think that they are described only the situation that inferenced by keras and trained by keras. I would like to inference by tensorflow after trained by keras. – Shota Aug 07 '18 at 08:05