Skip to content

Algorithm Factory

Source

Convenience function to create algorithm configurations.

algorithm_factory(algorithm)

Create an algorithm model for training CAREamics.

Parameters:

  • algorithm (dict) –

    Algorithm dictionary.

Returns:

create_algorithm_configuration(dimensions, algorithm, loss, independent_channels, n_channels_in, n_channels_out, use_n2v2=False, model_params=None, optimizer='Adam', optimizer_params=None, lr_scheduler='ReduceLROnPlateau', lr_scheduler_params=None)

Create a dictionary with the parameters of the algorithm model.

Parameters:

  • dimensions ((2, 3), default: 2 ) –

    Dimension of the model, either 2D or 3D.

  • algorithm ((n2v, care, n2n), default: "n2v" ) –

    Algorithm to use.

  • loss ((n2v, mae, mse), default: "n2v" ) –

    Loss function to use.

  • independent_channels (bool) –

    Whether to train all channels independently.

  • n_channels_in (int) –

    Number of input channels.

  • n_channels_out (int) –

    Number of output channels.

  • use_n2v2 (bool, default: false ) –

    Whether to use N2V2.

  • model_params (dict, default: None ) –

    UNetModel parameters.

  • optimizer ((Adam, Adamax, SGD), default: "Adam" ) –

    Optimizer to use.

  • optimizer_params (dict, default: None ) –

    Parameters for the optimizer, see PyTorch documentation for more details.

  • lr_scheduler ((ReduceLROnPlateau, StepLR), default: "ReduceLROnPlateau" ) –

    Learning rate scheduler to use.

  • lr_scheduler_params (dict, default: None ) –

    Parameters for the learning rate scheduler, see PyTorch documentation for more details.

Returns:

  • dict

    Algorithm model as dictionnary with the specified parameters.