Skip to content

N2V Configuration

Source

Configuration for N2V.

N2VConfiguration

Bases: Configuration

N2V-specific configuration.

data_config instance-attribute

Data configuration, holding all parameters required to configure the training data loader.

experiment_name instance-attribute

Name of the experiment, used to name logs and checkpoints.

training_config = Field(default_factory=default_training_factory) class-attribute instance-attribute

Training configuration, holding all parameters required to configure the training process.

version = '0.2.0' class-attribute instance-attribute

CAREamics configuration version.

__str__()

Pretty string reprensenting the configuration.

Returns:

  • str

    Pretty string.

get_algorithm_citations()

Return a list of citation entries of the current algorithm.

This is used to generate the model description for the BioImage Model Zoo.

Returns:

  • List[CiteEntry]

    List of citation entries.

get_algorithm_description()

Return a description of the algorithm.

This method is used to generate the README of the BioImage Model Zoo export.

Returns:

  • str

    Description of the algorithm.

get_algorithm_friendly_name()

Get the algorithm name.

Returns:

  • str

    Algorithm name.

get_algorithm_keywords()

Get algorithm keywords.

Returns:

get_algorithm_references()

Get the algorithm references.

This is used to generate the README of the BioImage Model Zoo export.

Returns:

  • str

    Algorithm references.

get_safe_experiment_name()

Return the experiment name safe for use in paths and filenames.

Spaces are replaced with underscores to avoid issues with folder creation and checkpoint naming.

Returns:

  • str

    Experiment name with spaces replaced with underscores.

is_supervised()

Return whether the algorithm is supervised.

This is true for CARE and N2N, and false for N2V. This is used to determine whether a target is required for training.

Returns:

  • bool

    True if the algorithm is supervised, False otherwise.

model_dump(**kwargs)

Override model_dump method in order to set default values.

As opposed to the parent model_dump method, this method sets exclude none by default.

Parameters:

  • **kwargs (Any, default: {} ) –

    Additional arguments to pass to the parent model_dump method.

Returns:

  • dict

    Dictionary containing the model parameters.

monitor_training_when_no_validation()

Validate that training loss is monitored when no validation data is used.

Returns:

  • Self

    Validated configuration.

Raises:

  • ValueError

    If no validation data is used and the monitored metric is not a training metric.

no_symbol(name) classmethod

Validate experiment name.

A valid experiment name is a non-empty string that only contains letters, numbers, underscores, dashes and spaces.

Parameters:

  • name (str) –

    Name to validate.

Returns:

  • str

    Validated name.

Raises:

  • ValueError

    If the name is empty or contains invalid characters.

set_3D(is_3D, axes, patch_size)

Set 3D flag and axes.

Parameters:

  • is_3D (bool) –

    Whether the algorithm is 3D or not.

  • axes (str) –

    Axes of the data.

  • patch_size (list[int]) –

    Patch size.

validate_3D()

Validate algorithm dimensions to match data dimensions.

Returns:

  • Self

    Validated configuration.

validate_channels_against_inputs()

Validate that the number of channels in the data is compatible with the model.

Returns:

  • Self

    Validated configuration.

validate_n2v_mask_pixel_perc()

Validate that there will always be at least one blind-spot pixel in every patch.

The probability of creating a blind-spot pixel is a function of the chosen masked pixel percentage and patch size.

Returns:

  • Self

    Validated configuration.

Raises:

  • ValueError

    If the probability of masking a pixel within a patch is less than 1 for the chosen masked pixel percentage and patch size.

validate_norm_against_channels()

Validate that normalization is compatible with the model in/out channels.

Returns:

  • Self

    Validated configuration.

validate_patch_against_model()

Validate that the patch size is compatible with the model constraints.

This is done by checking that the patch size is compatible with the model constraints.

Returns:

  • Self

    Validated configuration.

warn_batch_norm()

Warn if batch normalization is used with small batch size.

Returns:

  • Self

    Validated configuration.