tips:keras

This is an old revision of the document!


Keras

from keras import backend as K
from keras.models import load_model
import tensorflow as tf

K.set_learning_phase(0)

# create model and load weights or ...
# model = create_model()
# model.load_weights(path_to_h5)

# ... load h5 model
load_model(path_to_h5)
print("Output node: %s" % model.output.op.name)
saver = tf.train.Saver()
saver.save(K.get_session(), "/tmp/model.ckpt")

freeze

bazel-bin/tensorflow/python/tools/freeze_graph \
--input_meta_graph=model.ckpt/model.ckpt.meta  \
--input_checkpoint=model.ckpt/model.ckpt \
--output_graph=frozen_graph.pb --input_binary \
--output_node_names="previous output node name"
  
  print("Output node: %s" % model.output.op.name)
  saver = tf.train.Saver()
  saver.save(K.get_session(), "./"+export_path+"/model.ckpt")
  • tips/keras.1535029245.txt.gz
  • Last modified: 2018/08/23 15:00
  • by scipio