Skip to content

Image classifier test

Example showing how the test suite can be used to add tests for a new algorithm.

TestImageClassifier #

Bases: LightningModuleTests[ImageClassifier]

Tests for the ImageClassifier.

This runs all the tests included in the base class, with the given parametrizations:

  • algorithm_config will take the value "image_classifier"
    • This is because there is an image_classifier.yaml config file in project/configs/algorithms whose _target_ is the ImageClassifier.
  • datamodule_config will take these values: ['cifar10', 'fashion_mnist', 'imagenet', 'inaturalist', 'mnist']
    • These are all the configs whose target is an ImageClassificationDataModule.
  • Similarly, network_config will be parametrized by the names of all configs which produce an nn.Module, except those that would create a PreTrainedModel from HuggingFace.
    • This is currently the easiest way for us to say "any network for image classification.

Take a look at the LightningModuleTests class if you want to see the actual test code.

test_example_experiment_defaults #

test_example_experiment_defaults(
    experiment_config: Config,
) -> None

Test to check that the datamodule is required (even when just an algorithm is set?!).