Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SaveModel implementation #11

Open
giriannamalai opened this issue Jul 29, 2018 · 1 comment
Open

SaveModel implementation #11

giriannamalai opened this issue Jul 29, 2018 · 1 comment

Comments

@giriannamalai
Copy link

Hi,

I did tried to implement SavedModel in test.py, couldn't fix the issue.

sess = tf.Session()

# folder to export SavedModel
SavedModel_folder = "SavedModel"

# remove all explicit device specifications
clear_devices = True

# builds the SavedModel protocol buffer and saves variables and assets
builder = tf.saved_model.builder.SavedModelBuilder(SavedModel_folder)

# Restore metagraph
saver = tf.train.import_meta_graph('{}.meta'.format(os.path.join(FLAGS.run_dir, 'model', FLAGS.checkpoint)))
# Restore weights
saver.restore(sess, os.path.join(FLAGS.run_dir, 'model', FLAGS.checkpoint))

# Get tensors
input_x = graph.get_tensor_by_name('input_x:0')
input_y = graph.get_tensor_by_name('input_y:0')
keep_prob = graph.get_tensor_by_name('keep_prob:0')
predictions = graph.get_tensor_by_name('softmax/predictions:0')
accuracy = graph.get_tensor_by_name('accuracy/accuracy:0')

legacy_init_op = tf.group(tf.tables_initializer(), name='legacy_init_op')

prediction_signature = tf.saved_model.signature_def_utils.build_signature_def(
        inputs={'input_x:0': input_x, "input_y:0": input_y})

signature_def_map ={"serving_default": prediction_signature}

builder.add_meta_graph_and_variables(sess=sess,
    tags=[tf.saved_model.tag_constants.SERVING],
    signature_def_map=signature_def_map, legacy_init_op=legacy_init_op)

# writes a SavedModel protocol buffer to disk
builder.save()

"TypeError: Parameter to CopyFrom() must be instance of same class: expected tensorflow.TensorInfo got Tensor.
"

Can you fix/add a file to export to SaveModel?

@giriannamalai
Copy link
Author

giriannamalai commented Jul 29, 2018

--

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant