laymon
¶
Top-level package for PyLaymon.
Submodules¶
Package Contents¶
Classes¶
FeatureMapMonitoring () |
A wrapper class for adding a model or model layers for monitoring the feature maps |
FeatureMapObserver (layer, layer_name, update_display) |
An class used to create observers that are used to monitor the feature maps of the given layer. |
FeatureMapDisplay () |
A class for defining methods for displaying the parameters being monitored by a FeatureMapObserver. |
FeatureMapMonitor () |
A monitor type class for visualizing the feature maps of a neural network. |
-
class
laymon.
FeatureMapMonitoring
[source]¶ Bases:
object
A wrapper class for adding a model or model layers for monitoring the feature maps during training of the model.
-
add_layer
(self, layer, layer_name)¶ Adds the layer whose feature maps are to be monitored. :param layer: pyTorch layer :param layer_name: (str) name of the layer :return: the observer object of the layer being monitored
-
_add_layer
(self, layer, layer_name)¶ Create a observer class of the layer to be monitored and adds it to the list of observers being monitored. :param layer: pyTorch layer :param layer_name: (str) name of the layer :return: Observer object of the layer
-
_remove_layer
(self, layer_name)¶ Removes an observer from the list of observers being monitored. :param layer_name: name of the observer :return: True if observer was deleted, else False
-
remove_layer
(self, layer_name)¶ Remove the layer from list of layer being monitored. :param layer_name: str (name of the layer) :return: True if the layer is deleted from the list of monitored objects, else False
-
add_model
(self, model)¶ Registers all the layers a pyTorch model whose activations maps are to monitored. :param model: :return:
-
start
(self)¶ Starts monitoring the feature maps of the registered layers/model.
-
-
class
laymon.
FeatureMapObserver
(layer, layer_name, update_display)[source]¶ Bases:
laymon.interfaces.Observer
An class used to create observers that are used to monitor the feature maps of the given layer.
-
update
(self, parameters)¶ Update the display attached to the observer with the new parameters/activations. :param parameters: Tensor :return: None
-
get_layer_name
(self)¶ Returns the layer name being observed.
-
get_layer
(self)¶ Returns the layer object being observed.
-
-
class
laymon.
FeatureMapDisplay
¶ Bases:
laymon.interfaces.Display
A class for defining methods for displaying the parameters being monitored by a FeatureMapObserver.
-
display_params
(self, activation, max_subplots=5)¶ Method for updating the subplots and figure with the new parameters (activation maps).
-
_show
(self)¶
-
update_display
(self, parameters, display_title)¶ Updates the display with the new parameters :param parameters: Tensor (activation map params) :param display_title: Title of the figure
-
-
class
laymon.
FeatureMapMonitor
¶ Bases:
laymon.interfaces.Monitor
A monitor type class for visualizing the feature maps of a neural network.
-
add_observer
(self, layer_observer)¶ - Creates a layer observer object.
- Hooks the layer to capture the activation map of the layer.
- Adds the observer object to the list of monitored observers.
Parameters: layer_observer – Observer object
-
remove_observer
(self, layer_observer=None, layer_name=None)¶ - If the layer observer/layer name is in the list of monitored observers:
- Unhook the layer.
- Remove the layer observer from the list of monitored observers.
Parameters: - layer_observer – Layer Observer.
- layer_name – Name of the layer being monitored.
Returns: True/False based on whether the observer by deleted or not.
-
static
_is_layer_single_dim
(layer)¶ Checks if the layer is a single dimensional layer
-
_get_activation_map
(self, layer_name)¶ Hooks the layer to capture activation maps for the given layer and return the handler to the hook
-
notify_observers
(self)¶ Updates all the observers being monitored with the new parameters
-
get_registered_observers
(self)¶ Returns the list of observers being monitored.
-