ng_configuration
CAREamics configuration compatible with the NG Dataset.
NGConfiguration #
Bases: BaseModel
CAREamics configuration.
The configuration defines all parameters used to build and train a CAREamics model. These parameters are validated to ensure that they are compatible with each other.
It contains three sub-configurations:
- AlgorithmModel: configuration for the algorithm training, which includes the architecture, loss function, optimizer, and other hyperparameters.
- DataModel: configuration for the dataloader, which includes the type of data, transformations, mean/std and other parameters.
- TrainingModel: configuration for the training, which includes the number of epochs or the callbacks.
Attributes:
| Name | Type | Description |
|---|---|---|
experiment_name | str | Name of the experiment, used when saving logs and checkpoints. |
algorithm | AlgorithmModel | Algorithm configuration. |
data | DataModel | Data configuration. |
training | TrainingModel | Training configuration. |
Methods:
| Name | Description |
|---|---|
set_3D | Switch configuration between 2D and 3D. |
model_dump | exclude_defaults: bool = False, exclude_none: bool = True, **kwargs: Dict ) -> Dict Export configuration to a dictionary. |
Raises:
| Type | Description |
|---|---|
ValueError | Configuration parameter type validation errors. |
ValueError | If the experiment name contains invalid characters or is empty. |
ValueError | If the algorithm is 3D but there is not "Z" in the data axes, or 2D algorithm with "Z" in data axes. |
ValueError | Algorithm, data or training validation errors. |
Source code in src/careamics/config/ng_configs/ng_configuration.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
algorithm_config = Field(discriminator='algorithm') class-attribute instance-attribute #
Algorithm configuration, holding all parameters required to configure the model.
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 instance-attribute #
Training configuration, holding all parameters required to configure the training process.
version = '0.1.0' class-attribute instance-attribute #
CAREamics configuration version.
__str__() #
Pretty string reprensenting the configuration.
Returns:
| Type | Description |
|---|---|
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:
| Type | Description |
|---|---|
List[CiteEntry] | List of citation entries. |
Source code in src/careamics/config/ng_configs/ng_configuration.py
get_algorithm_description() #
Return a description of the algorithm.
This method is used to generate the README of the BioImage Model Zoo export.
Returns:
| Type | Description |
|---|---|
str | Description of the algorithm. |
Source code in src/careamics/config/ng_configs/ng_configuration.py
get_algorithm_friendly_name() #
Get the algorithm name.
Returns:
| Type | Description |
|---|---|
str | Algorithm name. |
get_algorithm_keywords() #
Get algorithm keywords.
Returns:
| Type | Description |
|---|---|
list[str] | List of keywords. |
get_algorithm_references() #
Get the algorithm references.
This is used to generate the README of the BioImage Model Zoo export.
Returns:
| Type | Description |
|---|---|
str | Algorithm references. |
Source code in src/careamics/config/ng_configs/ng_configuration.py
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:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs | Any | Additional arguments to pass to the parent model_dump method. | {} |
Returns:
| Type | Description |
|---|---|
dict | Dictionary containing the model parameters. |
Source code in src/careamics/config/ng_configs/ng_configuration.py
no_symbol(name) classmethod #
Validate experiment name.
A valid experiment name is a non-empty string with only contains letters, numbers, underscores, dashes and spaces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | Name to validate. | required |
Returns:
| Type | Description |
|---|---|
str | Validated name. |
Raises:
| Type | Description |
|---|---|
ValueError | If the name is empty or contains invalid characters. |
Source code in src/careamics/config/ng_configs/ng_configuration.py
validate_3D() #
Validate algorithm dimensions to match data dimensions.
Returns:
| Type | Description |
|---|---|
Self | Validated configuration. |