lucent package

Subpackages

lucent.util module

Utility functions

lucent.util.set_seed(seed)

Seeds all random number generators and enables deterministic cudnn. : param seed: seed value to seed the RNGs. Can e.g. be float or int.

lucent.model_utils module

Utility functions for models.

lucent.model_utils.add_to_dependence_graph(dependence_graph, prefix, name)
lucent.model_utils.filter_layer_names(layer_names, depth)
lucent.model_utils.get_model_layers(model: Module, getLayerRepr: Optional[bool] = False, dependencies: Optional[bool] = True, excludeNorms: Optional[bool] = True, excludeActs: Optional[bool] = True, excludePools: Optional[bool] = True) Union[List[str], OrderedDict]
Get the names of all layers of a network. The names are given in the format that can be used

to access them via objectives.

Parameters
  • model (torch.nn.Module) – the network to get the names of

  • getLayerRepr (Optional[bool], optional) – whether to return a OrderedDict of layer names, layer representation string pair. If False just return a list of names.

  • dependencies – Whether to return dependencies of layers as a nested OrderedDict

  • excludeNorms (Optional[bool], optional) – whether to exclude normalization layers, defaults to True

  • excludeActs (Optional[bool], optional) – whether to exclude Activation layers, defaults to True

  • excludePools (Optional[bool], optional) – whether to exclude Pooling layers, defaults to True

Rtype dependencies

Optional[bool], optional

Raises
  • ValueError – model has wrong type

  • ValueError – model has no modules

Returns

dict of name, repr pairs or just list of names of all layers (including activations if they are instantiated as layers)

Return type

Union[List[str], OrderedDict]

Module contents