Base Layers#
Classes#
- class BaseLayer(*, idx=0, group=0, version='', description='', **kwargs)[source]#
-
Base layer for other layers to inherit.
- Attributes:
- Parameters:
- idx
int,Optional Layer number, default = 0
- group
int,Optional Which group the layer belongs to, if 0 it will always be used, else it will only be used if the Network group matches the layer’s group, default = 0
- version
str,Optional Version of the network, default = netloader.__version__
- description
str,Optional Description of the layer
- **kwargs
Leftover parameters for checking if they are valid
- idx
- abstractmethod forward(x, *_, **__)[source]#
Forward pass for child layer ti implement.
- Parameters:
- x
Any Layer input
- x
- Returns:
AnyLayer output
- to(*args, **kwargs)[source]#
See
torch.nn.Module.to().
- class BaseSingleLayer(**kwargs)[source]#
Bases:
BaseLayerBase layer for layers that only use the previous layer.
- Attributes:
- group
int Layer group, if 0 it will always be used, else it will only be used if its group matches the Network’s
- description
str Description of the layer
- layers
Sequential Layers to loop through in the forward pass
- group
- Parameters:
- **kwargs
Leftover parameters to pass to base layer for checking
- forward(x, *_, **__)[source]#
Forward pass for a generic layer.
- Parameters:
- x
TensorListLike Input with tensors of shape (N,…) and type float, where N is the batch size
- x
- Returns:
TensorListLikeOutput with tensors of shape (N,…) and type float
- class BaseMultiLayer(net_check, layer, shapes, check_shapes, *, checkpoint=False, **kwargs)[source]#
Bases:
BaseLayerBase layer for layers that use earlier layers to inherit.
- Attributes:
- Parameters:
- net_checkbool
If layer index should be relative to checkpoint layers
- layer
int|list[int] Layer index(es) to concatenate the previous layer output with
- shapes
Shapes Shape of the outputs from each layer
- check_shapes
Shapes Shape of the outputs from each checkpoint
- checkpointbool,
Optional If layer index should be relative to checkpoint layers, default = False
- **kwargs
Leftover parameters to pass to base layer for checking
- extra_repr()[source]#
Displays layer parameters when printing the network.
- Returns:
strLayer parameters
- forward(x, *_, outputs, checkpoints, **__)[source]#
Forward pass to combine outputs from multiple layers.
- Parameters:
- x
TensorListLike Input with tensors of shape (N,…) and type float, where N is the batch size
- outputs
list[TensorListLike] Output from each layer with tensors of shape (N,…) and type float
- checkpoints
list[TensorListLike] Output from each checkpoint with tensors of shape (N,…) and type float
- x
- Returns:
TensorListLikeOutput with tensors of shape (N,…) and type float