Skip to content

training_signal

Training parameters set by the user.

TrainingSignal dataclass #

Training signal class.

This class holds the parameters required to run the training thread. These parameters should be set whenever the user interact with the corresponding UI elements. An instance of the class is then passed to the training worker.

Source code in src/careamics_napari/signals/training_signal.py
@evented
@dataclass
class TrainingSignal:
    """Training signal class.

    This class holds the parameters required to run the training thread. These
    parameters should be set whenever the user interact with the corresponding UI
    elements. An instance of the class is then passed to the training worker.
    """

    if TYPE_CHECKING:
        events: TrainingSignalGroup
        """Attribute allowing the registration of parameter-specific listeners."""

    # signals used to change states across widgets
    algorithm: str = "n2v"
    """Algorithm used for training."""

    use_channels: bool = False
    """Whether the data has channels."""

    is_3d: bool = False
    """Whether the data is 3D."""

    # parameters set by widgets for training
    work_dir: Path = HOME
    """Directory where the checkpoints and logs are saved."""

    load_from_disk: bool = True
    """Whether to load the images from disk or from the viewer."""

    if _has_napari:
        layer_train: Image = None
        """Layer containing the training data."""

        layer_train_target: Image = None
        """Layer containing the training target data."""

        layer_val: Image = None
        """Layer containing the validation data."""

        layer_val_target: Image = None
        """Layer containing the validation target data."""

    path_train: str = ""
    """Path to the training data."""

    path_train_target: str = ""
    """Path to the training target data."""

    path_val: str = ""
    """Path to the validation data."""

    path_val_target: str = ""
    """Path to the validation target."""

    axes: str = "YX"
    """Axes of the data."""

    patch_size_xy: int = 64
    """Size of the patches along the X and Y dimensions."""

    patch_size_z: int = 16
    """Size of the patches along the Z dimension."""

    n_epochs: int = 30
    """Number of epochs."""

    batch_size: int = 16
    """Batch size."""

    experiment_name = ""
    """Name of the experiment, used to export the model and save checkpoints."""

    x_flip: bool = True
    """Whether to apply flipping along the X dimension during augmentation."""

    y_flip: bool = True
    """Whether to apply flipping along the Y dimension during augmentation."""

    rotations: bool = True
    """Whether to apply rotations during augmentation."""

    independent_channels: bool = True
    """Whether to train the channels independently."""

    n_channels_n2v: int = 1
    """Number of channels when training Noise2Void."""

    n_channels_in_care: int = 1
    """Number of input channels when training CARE and Noise2Noise."""

    n_channels_out_care: int = 1
    """Number of output channels when training CARE and Noise2Noise."""

    use_n2v2: bool = False
    """Whether to use N2V2."""

    depth: int = 2
    """Depth of the U-Net."""

    num_conv_filters: int = 32
    """Number of convolutional filters in the first layer."""

    val_percentage: float = 0.1
    """Percentage of the training data used for validation."""

    val_minimum_split: int = 1
    """Minimum number of patches or images in the validation set."""

algorithm = 'n2v' class-attribute instance-attribute #

Algorithm used for training.

axes = 'YX' class-attribute instance-attribute #

Axes of the data.

batch_size = 16 class-attribute instance-attribute #

Batch size.

depth = 2 class-attribute instance-attribute #

Depth of the U-Net.

events instance-attribute #

Attribute allowing the registration of parameter-specific listeners.

experiment_name = '' class-attribute instance-attribute #

Name of the experiment, used to export the model and save checkpoints.

independent_channels = True class-attribute instance-attribute #

Whether to train the channels independently.

is_3d = False class-attribute instance-attribute #

Whether the data is 3D.

layer_train = None class-attribute instance-attribute #

Layer containing the training data.

layer_train_target = None class-attribute instance-attribute #

Layer containing the training target data.

layer_val = None class-attribute instance-attribute #

Layer containing the validation data.

layer_val_target = None class-attribute instance-attribute #

Layer containing the validation target data.

load_from_disk = True class-attribute instance-attribute #

Whether to load the images from disk or from the viewer.

n_channels_in_care = 1 class-attribute instance-attribute #

Number of input channels when training CARE and Noise2Noise.

n_channels_n2v = 1 class-attribute instance-attribute #

Number of channels when training Noise2Void.

n_channels_out_care = 1 class-attribute instance-attribute #

Number of output channels when training CARE and Noise2Noise.

n_epochs = 30 class-attribute instance-attribute #

Number of epochs.

num_conv_filters = 32 class-attribute instance-attribute #

Number of convolutional filters in the first layer.

patch_size_xy = 64 class-attribute instance-attribute #

Size of the patches along the X and Y dimensions.

patch_size_z = 16 class-attribute instance-attribute #

Size of the patches along the Z dimension.

path_train = '' class-attribute instance-attribute #

Path to the training data.

path_train_target = '' class-attribute instance-attribute #

Path to the training target data.

path_val = '' class-attribute instance-attribute #

Path to the validation data.

path_val_target = '' class-attribute instance-attribute #

Path to the validation target.

rotations = True class-attribute instance-attribute #

Whether to apply rotations during augmentation.

use_channels = False class-attribute instance-attribute #

Whether the data has channels.

use_n2v2 = False class-attribute instance-attribute #

Whether to use N2V2.

val_minimum_split = 1 class-attribute instance-attribute #

Minimum number of patches or images in the validation set.

val_percentage = 0.1 class-attribute instance-attribute #

Percentage of the training data used for validation.

work_dir = HOME class-attribute instance-attribute #

Directory where the checkpoints and logs are saved.

x_flip = True class-attribute instance-attribute #

Whether to apply flipping along the X dimension during augmentation.

y_flip = True class-attribute instance-attribute #

Whether to apply flipping along the Y dimension during augmentation.

TrainingSignalGroup #

Bases: SignalGroup

Signal group for the training status dataclass.

Source code in src/careamics_napari/signals/training_signal.py
class TrainingSignalGroup(SignalGroup):
    """Signal group for the training status dataclass."""

    # only parameters that have observers are listed here
    algorithm: SignalInstance
    """Algorithm used for training."""

    use_channels: SignalInstance
    """Whether tthe data has channels."""

    is_3d: SignalInstance
    """Whether the data is 3D."""

algorithm instance-attribute #

Algorithm used for training.

is_3d instance-attribute #

Whether the data is 3D.

use_channels instance-attribute #

Whether tthe data has channels.