Models¶
delira
comes with it’s own model-structure tree - with
AbstractNetwork
at it’s root - and integrates
several backends deeply into it’s structure.
AbstractNetwork¶
-
class
AbstractNetwork
(type)[source]¶ Bases:
object
Abstract class all networks should be derived from
-
_init_kwargs
= {}¶
-
abstract static
closure
(model, data_dict: dict, optimizers: dict, losses=None, metrics=None, fold=0, **kwargs)[source]¶ Function which handles prediction from batch, logging, loss calculation and optimizer step
- Parameters
model (
AbstractNetwork
) – model to forward data throughdata_dict (dict) – dictionary containing the data
optimizers (dict) – dictionary containing all optimizers to perform parameter update
losses (dict) – Functions or classes to calculate losses
metrics (dict) – Functions or classes to calculate other metrics
fold (int) – Current Fold in Crossvalidation (default: 0)
kwargs (dict) – additional keyword arguments
- Returns
dict – Metric values (with same keys as input dict metrics)
dict – Loss values (with same keys as input dict losses)
dict – Arbitrary number of predictions
- Raises
NotImplementedError – If not overwritten by subclass
-
property
init_kwargs
¶ Returns all arguments registered as init kwargs
- Returns
init kwargs
- Return type
-
static
prepare_batch
(batch: dict, input_device, output_device)[source]¶ Converts a numpy batch of data and labels to suitable datatype and pushes them to correct devices
- Parameters
batch (dict) – dictionary containing the batch (must have keys ‘data’ and ‘label’
input_device – device for network inputs
output_device – device for network outputs
- Returns
dictionary containing all necessary data in right format and type and on the correct device
- Return type
- Raises
NotImplementedError – If not overwritten by subclass
-