Python tensorflow.python.framework.graph_util_impl.remove_training_nodes() Examples
The following are 1
code examples of tensorflow.python.framework.graph_util_impl.remove_training_nodes().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tensorflow.python.framework.graph_util_impl
, or try the search function
.
Example #1
Source File: private_model.py From tf-encrypted with Apache License 2.0 | 6 votes |
def secure_model(model, **kwargs): """Secure a plaintext model from the current session.""" session = K.get_session() min_graph = graph_util.convert_variables_to_constants( session, session.graph_def, [node.op.name for node in model.outputs] ) graph_fname = "model.pb" tf.train.write_graph(min_graph, _TMPDIR, graph_fname, as_text=False) if "batch_size" in kwargs: batch_size = kwargs.pop("batch_size") else: batch_size = 1 graph_def, inputs = load_graph( os.path.join(_TMPDIR, graph_fname), batch_size=batch_size ) c = tfe.convert.convert.Converter(tfe.convert.registry(), **kwargs) y = c.convert(remove_training_nodes(graph_def), "input-provider", inputs) return PrivateModel(y)