Selection#

class deeplay.module.Selection(*args, **kwargs)#

Bases: DeeplayModule

Methods Summary

append(*args, **kwargs)

Applies SequentialBlock.append to all modules in the selection.

append_dropout(*args, **kwargs)

Applies SequentialBlock.append_dropout to all modules in the selection.

configure(*args, **kwargs)

Applies DeeplayModule.configure to all modules in the selection.

filter(func)

Filter the selection based on a function that takes the module name (separated by .) and module as input.

hasattr(attr[, strict, include_layer_classtype])

Filter the selection based on whether the modules have a certain attribute.

insert(*args, **kwargs)

Applies SequentialBlock.insert to all modules in the selection.

insert_dropout(*args, **kwargs)

Applies SequentialBlock.insert_dropout to all modules in the selection.

isinstance(cls[, include_layer_classtype])

Filter the selection based on whether the modules are instances of a certain class.

list_names()

log_input(key)

Applies DeeplayModule.log_input to the first module in the selection.

log_output(key)

Applies DeeplayModule.log_output to the first module in the selection.

prepend(*args, **kwargs)

Applies SequentialBlock.prepend to all modules in the selection.

prepend_dropout(*args, **kwargs)

Applies SequentialBlock.prepend_dropout to all modules in the selection.

remove(*args, **kwargs)

Applies SequentialBlock.remove to all modules in the selection.

remove_dropout(*args, **kwargs)

Applies SequentialBlock.remove_dropout to all modules in the selection.

replace(*args, **kwargs)

Applies DeeplayModule.replace to all modules in the selection.

set_dropout(*args, **kwargs)

Applies SequentialBlock.set_dropout to all modules in the selection.

set_input_map(*args, **kwargs)

Applies DeeplayModule.set_input_map to all modules in the selection.

set_output_map(*args, **kwargs)

Applies DeeplayModule.set_output_map to all modules in the selection.

Methods Documentation

append(*args, **kwargs)#

Applies SequentialBlock.append to all modules in the selection.

append_dropout(*args, **kwargs)#

Applies SequentialBlock.append_dropout to all modules in the selection.

configure(*args, **kwargs)#

Applies DeeplayModule.configure to all modules in the selection.

filter(func: Callable[[str, Module], bool]) Selection#

Filter the selection based on a function that takes the module name (separated by .) and module as input.

Parameters#

funcCallable[[str, nn.Module], bool]

A function that takes the module name (separated by .) and module as input and returns a boolean.

Returns#

Selection

A new selection with the modules that satisfy the condition.

hasattr(attr: str, strict=True, include_layer_classtype: bool = True) Selection#

Filter the selection based on whether the modules have a certain attribute.

Note, for layers, the attribute is checked in the layer’s classtype (if include_layer_classtype is True). However, this does not include non-class attributes of the layer since they are not accessible from the layer’s classtype. For example, Selection(Layer(nn.Conv2d)).hasattr(“kernel_size”) will return False, but Selection(Layer(nn.Conv2d)).hasattr(“_conv_forward”) will return True.

Parameters#

attrstr

The attribute to check for.

strictbool, optional

Whether to only accept real attributes and methods. This excludes properties. By default True

include_layer_classtypebool, optional

Whether to check the attribute in the layer’s classtype, by default True

Returns#

Selection

A new selection with the modules that have the attribute.

insert(*args, **kwargs)#

Applies SequentialBlock.insert to all modules in the selection.

insert_dropout(*args, **kwargs)#

Applies SequentialBlock.insert_dropout to all modules in the selection.

isinstance(cls: type, include_layer_classtype: bool = True) Selection#

Filter the selection based on whether the modules are instances of a certain class.

Note, for layers, the class is checked in the layer’s classtype (if include_layer_classtype is True).

Parameters#

clstype

The class to check for.

include_layer_classtypebool, optional

Whether to check the class in the layer’s classtype, by default True

Returns#

Selection

A new selection with the modules that are instances of the class.

list_names()#
log_input(key)#

Applies DeeplayModule.log_input to the first module in the selection.

log_output(key)#

Applies DeeplayModule.log_output to the first module in the selection.

prepend(*args, **kwargs)#

Applies SequentialBlock.prepend to all modules in the selection.

prepend_dropout(*args, **kwargs)#

Applies SequentialBlock.prepend_dropout to all modules in the selection.

remove(*args, **kwargs)#

Applies SequentialBlock.remove to all modules in the selection.

remove_dropout(*args, **kwargs)#

Applies SequentialBlock.remove_dropout to all modules in the selection.

replace(*args, **kwargs)#

Applies DeeplayModule.replace to all modules in the selection.

set_dropout(*args, **kwargs)#

Applies SequentialBlock.set_dropout to all modules in the selection.

set_input_map(*args, **kwargs)#

Applies DeeplayModule.set_input_map to all modules in the selection.

set_output_map(*args, **kwargs)#

Applies DeeplayModule.set_output_map to all modules in the selection.