unet_config
UNet Pydantic model.
UNetConfig #
Bases: ArchitectureConfig
Pydantic model for a N2V(2)-compatible UNet.
Attributes:
| Name | Type | Description |
|---|---|---|
depth | int | Depth of the model, between 1 and 10 (default 2). |
num_channels_init | int | Number of filters of the first level of the network, should be even and minimum 8 (default 96). |
Source code in src/careamics/config/architectures/unet_config.py
14 15 16 17 18 19 20 21 22 23 24 25 26 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 | |
architecture instance-attribute #
Name of the architecture.
conv_dims = Field(default=2, validate_default=True) class-attribute instance-attribute #
Dimensions (2D or 3D) of the convolutional layers.
depth = Field(default=2, ge=1, le=10, validate_default=True) class-attribute instance-attribute #
Number of levels in the UNet.
final_activation = Field(default='None', validate_default=True) class-attribute instance-attribute #
Final activation function.
in_channels = Field(default=1, ge=1, validate_default=True) class-attribute instance-attribute #
Number of channels in the input to the model.
independent_channels = Field(default=True, validate_default=True) class-attribute instance-attribute #
Whether information is processed independently in each channel, used to train channels independently.
n2v2 = Field(default=False, validate_default=True) class-attribute instance-attribute #
Whether to use N2V2 architecture modifications, with blur pool layers and fewer skip connections.
num_channels_init = Field(default=32, ge=8, le=1024, validate_default=True) class-attribute instance-attribute #
Number of convolutional filters in the first layer of the UNet.
num_classes = Field(default=1, ge=1, validate_default=True) class-attribute instance-attribute #
Number of classes or channels in the model output.
residual = Field(default=False, validate_default=True) class-attribute instance-attribute #
Whether to add a residual connection from the input to the output.
use_batch_norm = Field(default=True, validate_default=True) class-attribute instance-attribute #
Whether to use batch normalization in the model.
get_num_input_channels() #
Get the number of input channels.
Returns:
| Type | Description |
|---|---|
int | Number of input channels. |
get_num_output_channels() #
Get the number of output channels.
Returns:
| Type | Description |
|---|---|
int | Number of output channels. |
is_3D() #
Return whether the model is 3D or not.
This method is used in the NG configuration validation to check that the model dimensions match the data dimensions.
Returns:
| Type | Description |
|---|---|
bool | Whether the model is 3D or not. |
Source code in src/careamics/config/architectures/unet_config.py
set_3D(is_3D) #
Set 3D model by setting the conv_dims parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
is_3D | bool | Whether the algorithm is 3D or not. | required |
Source code in src/careamics/config/architectures/unet_config.py
validate_num_channels_init(num_channels_init) classmethod #
Validate that num_channels_init is even.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_channels_init | int | Number of channels. | required |
Returns:
| Type | Description |
|---|---|
int | Validated number of channels. |
Raises:
| Type | Description |
|---|---|
ValueError | If the number of channels is odd. |