I have a keras model **model.h5**. I'm trying to convert it to a model.pb basically tensorflow format. For that I need to load the model first. When I tried to load the model using **load_model**, I'm getting this exception **ValueError: No model found in config file.**. Here is my complete code
import tensorflow as tf
from tensorflow.contrib.keras.python.keras import backend as K
from tensorflow.contrib.keras.python.keras.models import load_model, Sequential
from tensorflow.python.saved_model import builder as saved_model_builder
from tensorflow.python.saved_model import tag_constants, signature_constants
from tensorflow.python.saved_model.signature_def_utils_impl import predict_signature_def
sess = tf.Session()
K.set_session(sess)
# disable loading of learning nodes
K.set_learning_phase(0)
# load model
model = load_model('build/model.h5')
config = model.get_config()
weights = model.get_weights()
new_Model = Sequential.from_config(config)
new_Model.set_weights(weights)
# export current best model
export_path = "build/tensorflow_model/"
builder = saved_model_builder.SavedModelBuilder(export_path)
signature = predict_signature_def(inputs={'accelerations': new_Model.input},
outputs={'scores': new_Model.output})
with K.get_session() as sess:
builder.add_meta_graph_and_variables(sess=sess,
tags=[tag_constants.SERVING],
signature_def_map={
signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY: signature})
builder.save()
**Exception**
2017-06-07 21:27:21.505316: I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1060, pci bus id: 0000:01:00.0)
Traceback (most recent call last):
File "C:/Users/Skanda/OneDrive/Playground/Fault-Classification/FaultTypeClassification/predict.py", line 28, in <module>
model = load_model('C:/Users/Skanda/OneDrive/Playground/Fault-Classification/FaultTypeClassification/build/model.h5')
File "D:\Programs\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\contrib\keras\python\keras\models.py", line 259, in load_model
raise ValueError('No model found in config file.')
ValueError: No model found in config file.