Skip to content

Example

Example of a simple algorithm for image classification.

This can be run from the command-line like so:

python project/main.py algorithm=example

ExampleAlgorithm #

Bases: LightningModule

Example learning algorithm for image classification.

__init__ #

__init__(
    datamodule: ImageClassificationDataModule,
    network: _Config[Module],
    optimizer: _PartialConfig[Optimizer] = AdamConfig(
        lr=0.0003
    ),
    init_seed: int = 42,
)

Create a new instance of the algorithm.

Parameters:

Name Type Description Default
datamodule ImageClassificationDataModule

Object used to load train/val/test data. See the lightning docs for LightningDataModule for more info.

required
network _Config[Module]

The config of the network to instantiate and train.

required
optimizer _PartialConfig[Optimizer]

The config for the Optimizer. Instantiating this will return a function (a functools.partial) that will create the Optimizer given the hyper-parameters.

AdamConfig(lr=0.0003)
init_seed int

The seed to use when initializing the weights of the network.

42