本文整理汇总了Python中caffe2.python.net_drawer.GetPydotGraphMinimal方法的典型用法代码示例。如果您正苦于以下问题:Python net_drawer.GetPydotGraphMinimal方法的具体用法?Python net_drawer.GetPydotGraphMinimal怎么用?Python net_drawer.GetPydotGraphMinimal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类caffe2.python.net_drawer
的用法示例。
在下文中一共展示了net_drawer.GetPydotGraphMinimal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_graph
# 需要导入模块: from caffe2.python import net_drawer [as 别名]
# 或者: from caffe2.python.net_drawer import GetPydotGraphMinimal [as 别名]
def save_graph(net, file_name, graph_name="net", op_only=True):
from caffe2.python import net_drawer
graph = None
ops = net.op
if not op_only:
graph = net_drawer.GetPydotGraph(
ops, graph_name,
rankdir="TB")
else:
graph = net_drawer.GetPydotGraphMinimal(
ops, graph_name,
rankdir="TB", minimal_dependency=True)
try:
graph.write_png(file_name)
except Exception as e:
print('Error when writing graph to image {}'.format(e))
示例2: save_graph_base
# 需要导入模块: from caffe2.python import net_drawer [as 别名]
# 或者: from caffe2.python.net_drawer import GetPydotGraphMinimal [as 别名]
def save_graph_base(net, file_name, graph_name="net", op_only=True, blob_rename_func=None):
graph = None
ops = net.op
if blob_rename_func is not None:
ops = _modify_blob_names(ops, blob_rename_func)
if not op_only:
graph = net_drawer.GetPydotGraph(ops, graph_name, rankdir="TB")
else:
graph = net_drawer.GetPydotGraphMinimal(
ops, graph_name, rankdir="TB", minimal_dependency=True
)
try:
par_dir = os.path.dirname(file_name)
if not os.path.exists(par_dir):
os.makedirs(par_dir)
format = os.path.splitext(os.path.basename(file_name))[-1]
if format == ".png":
graph.write_png(file_name)
elif format == ".pdf":
graph.write_pdf(file_name)
elif format == ".svg":
graph.write_svg(file_name)
else:
print("Incorrect format {}".format(format))
except Exception as e:
print("Error when writing graph to image {}".format(e))
return graph
# ==== torch/utils_toffee/aten_to_caffe2.py ====================================