ocl.utils.routing
Utility function related to routing of information.
These utility functions allow dynamical routing between modules and allow the specification of complex models using config alone.
RoutableMixin
Mixin class that allows to connect any element of a (nested) dict with a module input.
Source code in ocl/utils/routing.py
DataRouter
Bases: nn.Module
, RoutableMixin
Data router for modules that don't support the RoutableMixin.
This allows the usage of modules without RoutableMixin support in the dynamic information flow pattern of the code.
Source code in ocl/utils/routing.py
Combined
Bases: nn.ModuleDict
Module to combine multiple modules and store their outputs.
A combined module groups together multiple model components and allows them to access any information that was returned in processing steps prior to their own application.
It functions similarly to nn.ModuleDict
yet for modules of type RoutableMixin
and
additionally implements a forward routine which will return a dict of the outputs of the
submodules.
Source code in ocl/utils/routing.py
Recurrent
Module to apply another module in a recurrent fashion over a axis.
This module takes a set of input tensors and applies a module recurrent over them. The output
of the previous iteration is kept in the previous_output
key of input dict and thus can be
accessed using data routing. After applying the module to the input slices, the outputs are
stacked along the same axis as the inputs where split.
Source code in ocl/utils/routing.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
__init__
Initialize recurrent module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module |
nn.Module
|
The module that should be applied recurrently along input tensors. |
required |
inputs_to_split |
List[str]
|
List of paths that should be split for recurrent application. |
required |
initial_input_mapping |
Dict[str, str]
|
Mapping that constructs the first |
required |
split_axis |
int
|
Axis along which to split the tensors defined by inputs_to_split. |
1
|
chunk_size |
int
|
The size of each slice, when set to 1, the slice dimension is squeezed prior to passing to the module. |
1
|