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,
)
| 30 | |
| 31 | |
| 32 | def 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 |
no test coverage detected