本文整理匯總了Python中tensorflow.python.framework.graph_util_impl.remove_training_nodes方法的典型用法代碼示例。如果您正苦於以下問題:Python graph_util_impl.remove_training_nodes方法的具體用法?Python graph_util_impl.remove_training_nodes怎麽用?Python graph_util_impl.remove_training_nodes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tensorflow.python.framework.graph_util_impl
的用法示例。
在下文中一共展示了graph_util_impl.remove_training_nodes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: secure_model
# 需要導入模塊: from tensorflow.python.framework import graph_util_impl [as 別名]
# 或者: from tensorflow.python.framework.graph_util_impl import remove_training_nodes [as 別名]
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)