本文整理汇总了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)