Skip to content

Commit

Permalink
Add clear_devices when exporting models
Browse files Browse the repository at this point in the history
  • Loading branch information
tobegit3hub committed Apr 27, 2017
1 parent 2a03979 commit c29f742
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion dense_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ def inference(inputs, is_train=True):
builder.add_meta_graph_and_variables(
sess,
[tag_constants.SERVING],
clear_devices=True,
signature_def_map={
signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY:
model_signature,
Expand Down Expand Up @@ -575,7 +576,8 @@ def export_model(sess, saver, signature, model_path, model_version):
logging.info("Export the model to {}".format(model_path))
model_exporter = exporter.Exporter(saver)
model_exporter.init(sess.graph.as_graph_def(),
named_graph_signatures=signature)
named_graph_signatures=signature,
clear_devices=True)
try:
model_exporter.export(model_path, tf.constant(model_version), sess)
except Exception as e:
Expand Down
4 changes: 3 additions & 1 deletion sparse_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ def inference(sparse_ids, sparse_values, is_train=True):
builder.add_meta_graph_and_variables(
sess,
[tag_constants.SERVING],
clear_devices=True,
signature_def_map={
signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY:
model_signature,
Expand Down Expand Up @@ -535,7 +536,8 @@ def export_model(sess, saver, signature, model_path, model_version):
logging.info("Export the model to {}".format(model_path))
model_exporter = exporter.Exporter(saver)
model_exporter.init(sess.graph.as_graph_def(),
named_graph_signatures=signature)
named_graph_signatures=signature,
clear_devices=True)
try:
model_exporter.export(model_path, tf.constant(model_version), sess)
except Exception as e:
Expand Down

0 comments on commit c29f742

Please sign in to comment.