mindspore.dataset.debug.DebugHook
- class mindspore.dataset.debug.DebugHook(prev_op_name=None)[source]
The base class for Dataset Pipeline Python Debugger hook. All user defined hook behaviors must inherit this base class.
To debug the input and output data of map operation in dataset pipeline, users can add breakpoint in compute method, or print types and shapes of the data.
- Parameters
prev_op_name (str, optional) – name of the operation before current debugging point. Default:
None
.
Examples
>>> import mindspore.dataset as ds >>> import mindspore.dataset.debug as debug >>> >>> class CustomizedHook(debug.DebugHook): ... def __init__(self): ... super().__init__() ... ... def compute(self, *args): ... import pdb ... pdb.set_trace() ... print("Data after decode", *args) ... return args >>> >>> # Enable debug mode >>> ds.config.set_debug_mode(True, debug_hook_list=[CustomizedHook()]) >>> >>> # Define dataset pipeline >>> dataset = ds.ImageFolderDataset(dataset_dir="/path/to/image_folder_dataset_directory") >>> # Insert debug hook after `Decode` operation. >>> dataset = dataset.map([vision.Decode(), CustomizedHook(), vision.CenterCrop(100)])