当前位置: 首页>>代码示例>>Python>>正文


Python net_drawer.GetPydotGraph方法代码示例

本文整理汇总了Python中caffe2.python.net_drawer.GetPydotGraph方法的典型用法代码示例。如果您正苦于以下问题:Python net_drawer.GetPydotGraph方法的具体用法?Python net_drawer.GetPydotGraph怎么用?Python net_drawer.GetPydotGraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在caffe2.python.net_drawer的用法示例。


在下文中一共展示了net_drawer.GetPydotGraph方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_graph

# 需要导入模块: from caffe2.python import net_drawer [as 别名]
# 或者: from caffe2.python.net_drawer import GetPydotGraph [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)) 
开发者ID:yihui-he,项目名称:KL-Loss,代码行数:19,代码来源:model_convert_utils.py

示例2: save_graph_base

# 需要导入模块: from caffe2.python import net_drawer [as 别名]
# 或者: from caffe2.python.net_drawer import GetPydotGraph [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 ==================================== 
开发者ID:facebookresearch,项目名称:detectron2,代码行数:35,代码来源:shared.py


注:本文中的caffe2.python.net_drawer.GetPydotGraph方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。