dlt.viz¶
Images¶
imshow¶
-
dlt.viz.
imshow
(img, view='torch', figure=None, pause=0, title=None, interactive=False, *args, **kwargs)¶ Displays a Tensor or Array image to screen.
Parameters: - img (Tensor or Array) – Image to display.
- view (str, optional) – View of image. For more details see
dlt.util.change_view()
(default ‘torch’). - figure (python:int, optional) – Use selected figure (default None).
- pause (python:float, optional) – Number of seconds to pause execution for displaying when interactive is True. If a value less than 1e-2 is given then it defaults to 1e-2 (default 1e-2).
- title (str, optional) – Title for figure (default None).
- interactive (bool, optional) – If the image will be updated; uses plt.ion() (default False).
- *args (optional) – Extra arguments to be passed to plt.imshow().
- **kwargs (optional) – Extra keyword arguments to be passed to plt.imshow().
Example
>>> for video_1_frame, video_2_frame in two_videos_frames: >>> dlt.viz.imshow(video_1_frame, view='cv', figure=1, interactive=True, title='Video 1') >>> dlt.viz.imshow(video_2_frame, view='cv', figure=2, interactive=True, title='Video 2')
Models¶
forward¶
-
dlt.viz.modules.
forward_hook
(net, modules=None, match_names=None, do_input=False, do_output=True, tag='', save_path='.', replace=True, histogram=True, bins=100)¶ Registers a forward hook to a network’s modules for vizualization of the inputs and outputs.
When net.forward() is called, the hook saves an image grid or a histogram of input/output of the specified modules.
Parameters: - net (nn.Module) – The network whose modules are to be visualized.
- modules (list or tuple, optional) – List of class definitions for the modules where the hook is attached e.g. nn.Conv2d (default None).
- match_names (list or tuple, optional) – List of strings. If any modules contain one of the strings then the hook is attached (default None).
- do_input (bool, optional) – If True the input of the module is visualized (default False).
- do_output (bool, optional) – If True the output of the module is visualized (default True).
- tag (str, optional) – String tag to attach to saved images (default None).
- save_path (str, optional) – Path to save visualisation results (default ‘.’).
- replace (bool, optional) – If True, the images (from the same module) are replaced whenever the hook is called (default True).
- histogram (bool, optional) – If True then the visualization is a histrogram, otherwise it’s an image grid.
- bins (bool, optional) – Number of bins for histogram, if histogram is True (default 100).
Note
- If modules or match_names are not provided then no hooks will be attached.
backward¶
-
dlt.viz.modules.
backward_hook
(net, modules=None, match_names=None, do_grad_input=False, do_grad_output=True, tag='', save_path='.', replace=True, histogram=True, bins=100)¶ Registers a backward hook to a network’s modules for vizualization of the gradients.
When net.backward() is called, the hook saves an image grid or a histogram of grad_input/grad_output of the specified modules.
Parameters: - net (nn.Module) – The network whose gradients are to be visualized.
- modules (list or tuple, optional) – List of class definitions for the modules where the hook is attached e.g. nn.Conv2d (default None).
- match_names (list or tuple, optional) – List of strings. If any modules contain one of the strings then the hook is attached (default None).
- do_grad_input (bool, optional) – If True the grad_input of the module is visualized (default False).
- do_grad_output (bool, optional) – If True the grad_output of the module is visualized (default True).
- tag (str, optional) – String tag to attach to saved images (default None).
- save_path (str, optional) – Path to save visualisation results (default ‘.’).
- replace (bool, optional) – If True, the images (from the same module) are replaced whenever the hook is called (default True).
- histogram (bool, optional) – If True then the visualization is a histrogram, otherwise it’s an image grid.
- bins (bool, optional) – Number of bins for histogram, if histogram is True (default 100).
Note
- If modules or match_names are not provided then no hooks will be attached.
parameters_hooked¶
-
dlt.viz.modules.
parameters_hook
(net, modules=None, match_names=None, param_names=None, tag='', save_path='.', replace=True, histogram=True, bins=100)¶ Registers a forward hook to a network’s modules for vizualization of its parameters.
When net.forward() is called, the hook saves an image grid or a histogram of the parameters of the specified modules.
Parameters: - net (nn.Module) – The network whose parameters are to be visualized.
- modules (list or tuple, optional) – List of class definitions for the modules where the hook is attached e.g. nn.Conv2d (default None).
- match_names (list or tuple, optional) – List of strings. If any modules contain one of the strings then the hook is attached (default None).
- param_names (list or tuple, optional) – List of strings. If any parameters of the module contain one of the strings then they are visualized (default None).
- tag (str, optional) – String tag to attach to saved images (default None).
- save_path (str, optional) – Path to save visualisation results (default ‘.’).
- replace (bool, optional) – If True, the images (from the same module) are replaced whenever the hook is called (default True).
- histogram (bool, optional) – If True then the visualization is a histrogram, otherwise it’s an image grid.
- bins (bool, optional) – Number of bins for histogram, if histogram is True (default 100).
Note
- If modules or match_names are not provided then no hooks will be attached.
- If param_names are not provided then no parameters will be visualized.
parameters_once¶
-
dlt.viz.modules.
parameters
(net, modules=None, match_names=None, param_names=None, tag='', save_path='.', histogram=True, bins=100)¶ Visualizes a network’s parameters on an image grid or histogram.
Parameters: - net (nn.Module) – The network whose parameters are to be visualized.
- modules (list or tuple, optional) – List of class definitions for the modules where the hook is attached e.g. nn.Conv2d (default None).
- match_names (list or tuple, optional) – List of strings. If any modules contain one of the strings then the hook is attached (default None).
- param_names (list or tuple, optional) – List of strings. If any parameters of the module contain one of the strings then they are visualized (default None).
- tag (str, optional) – String tag to attach to saved images (default None).
- save_path (str, optional) – Path to save visualisation results (default ‘.’).
- histogram (bool, optional) – If True then the visualization is a histrogram, otherwise it’s an image grid.
- bins (bool, optional) – Number of bins for histogram, if histogram is True (default 100).
Note
- If modules or match_names are not provided then no parameters will be visualized.
- If param_names are not provided then no parameters will be visualized.