當前位置: 首頁>>代碼示例>>Python>>正文


Python net_drawer.GetPydotGraphMinimal方法代碼示例

本文整理匯總了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)) 
開發者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 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 ==================================== 
開發者ID:facebookresearch,項目名稱:detectron2,代碼行數:35,代碼來源:shared.py


注:本文中的caffe2.python.net_drawer.GetPydotGraphMinimal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。