MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / visualize

Function visualize

imperative/python/megengine/tools/network_visualize.py:32–276  ·  view source on GitHub ↗

r"""Load megengine dumped model and visualize graph structure with tensorboard log files. Can also record and print model's statistics like :func:`~.module_stats` Args: model_path: dir path for megengine dumped model. log_path: dir path for tensorboard graph log. input: us

(
    model_path: str,
    log_path: str,
    input: np.ndarray = None,
    inp_dict: dict = None,
    cal_params: bool = True,
    cal_flops: bool = True,
    cal_activations: bool = True,
    logging_to_stdout: bool = True,
    bar_length_max: int = 20,
)

Source from the content-addressed store, hash-verified

30
31
32def visualize(
33 model_path: str,
34 log_path: str,
35 input: np.ndarray = None,
36 inp_dict: dict = None,
37 cal_params: bool = True,
38 cal_flops: bool = True,
39 cal_activations: bool = True,
40 logging_to_stdout: bool = True,
41 bar_length_max: int = 20,
42):
43 r"""Load megengine dumped model and visualize graph structure with tensorboard log files.
44 Can also record and print model's statistics like :func:`~.module_stats`
45
46 Args:
47 model_path: dir path for megengine dumped model.
48 log_path: dir path for tensorboard graph log.
49 input: user defined input data for running model and calculating stats,
50 alternative with inp_dict, used when the model has only one input.
51 inp_dict: input dict for running model and calculating stats, alternative with
52 input, used when the model has more than one input.
53 When both input and inp_dict are None, a random input will be used.
54 cal_params: whether calculate and record params size.
55 cal_flops: whether calculate and record op flops.
56 cal_activations: whether calculate and record op activations.
57 logging_to_stdout: whether print all calculated statistic details.
58 bar_length_max: size of bar indicating max flops or parameter size in net stats.
59 model_path: str:
60 log_path: str:
61 input: np.ndarray:
62 inp_dict: dict:
63 cal_params: bool:
64 cal_flops: bool:
65 cal_activations: bool:
66 logging_to_stdout: bool:
67 bar_length_max: int:
68 """
69 if log_path:
70 try:
71 from tensorboard.compat.proto.attr_value_pb2 import AttrValue
72 from tensorboard.compat.proto.config_pb2 import RunMetadata
73 from tensorboard.compat.proto.graph_pb2 import GraphDef
74 from tensorboard.compat.proto.node_def_pb2 import NodeDef
75 from tensorboard.compat.proto.step_stats_pb2 import (
76 AllocatorMemoryUsed,
77 DeviceStepStats,
78 NodeExecStats,
79 StepStats,
80 )
81 from tensorboard.compat.proto.tensor_shape_pb2 import TensorShapeProto
82 from tensorboard.compat.proto.versions_pb2 import VersionDef
83 from tensorboardX import SummaryWriter
84 except ImportError:
85 logger.error(
86 "TensorBoard and TensorboardX are required for visualize.",
87 exc_info=True,
88 )
89 return

Callers 1

mainFunction · 0.85

Calls 15

enable_receptive_fieldFunction · 0.90
get_op_statsFunction · 0.90
sizeof_fmtFunction · 0.90
get_activation_statsFunction · 0.90
get_param_statsFunction · 0.90
sum_param_statsFunction · 0.90
print_param_statsFunction · 0.90
sum_op_statsFunction · 0.90
print_op_statsFunction · 0.90
sum_activations_statsFunction · 0.90
print_activations_statsFunction · 0.90
print_summaryFunction · 0.90

Tested by

no test coverage detected