python - Tensorflow ValueError:cannot convert a tensor of type float32 to an input of type float32_ref, when trying to load a model saved as .pb -


i have trained tensorflow model saved in form of checkpoint, .data, .meta, , .index file. model uses batch normalization. tried converting .pb file using freeze_graph, can imported from tensorflow.python.tools import freeze_graph. input .pb file 1 has graph structure. restore model following code

sess = tf.session() saver = tf.train.import_meta_graph(r'.\path\to\model\vanillacnn.0000.meta')  saver.restore(sess, tf.train.latest_checkpoint(r'.\path\to\model')) graph = tf.get_default_graph() 

then .pb file contains graph structure created with

tf.train.write_graph(sess.graph_def, "", "model_proto.pb", false) 

after use freeze_graph generate .pb file includes graph structure weights. inputs freeze_graph

input_graph_path = r'.\path\to\model\model_proto.pb' input_saver_def_path = "" input_binary = false input_checkpoint_path = r'.\path\to\model\vanillacnn.0000' output_node_names = "vanillacnnoutput_10/layer_output" restore_op_name = "save/restore_all" filename_tensor_name = "save/const:0" output_graph_path = r'.\path\to\model\frozen_model.pb' clear_devices = false initializer_nodes="" 

executed

freeze_graph.freeze_graph(input_graph_path, input_saver_def_path,input_binary, input_checkpoint_path,output_node_names, restore_op_name,filename_tensor_name, output_graph_path,clear_devices,initializer_nodes) 

this creates frozen_model.pb, when try load below

def load_graph(frozen_graph_filename):     tf.gfile.gfile(frozen_graph_filename, "rb") f:         graph_def = tf.graphdef()         graph_def.parsefromstring(f.read())      tf.graph().as_default() graph:         tf.import_graph_def(graph_def, input_map=none, return_elements=none, name="", op_dict=none, producer_op_list=none)     return graph 

it throws following error

valueerror: graph_def invalid @ node 'vanillacnnconv_0/vanillacnnconv_0/cond/assign': input tensor 'vanillacnnconv_0/vanillacnnconv_0/cond/assign/switch:1' cannot convert tensor of type float32 input of type float32_ref. 

how can fix this?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -