Block Factories¤
pdequinox.blocks.ClassicDoubleConvBlockFactory
¤
Bases: BlockFactory
Source code in pdequinox/blocks/_classic_double_conv_block.py
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 |
|
__init__
¤
__init__(
*,
kernel_size: int = 3,
use_norm: bool = True,
num_groups: int = 1,
use_bias: bool = True,
zero_bias_init: bool = False
)
Factory for creating ClassicDoubleConvBlock
instances.
Arguments:
kernel_size
: The size of the convolutional kernel. Default is3
.use_norm
: Whether to use group normalization. Default isTrue
.num_groups
: The number of groups to use for group normalization. Default is1
.use_bias
: Whether to use bias in the convolutional layers. Default isTrue
.zero_bias_init
: Whether to initialise the bias to zero. Default isFalse
.
Source code in pdequinox/blocks/_classic_double_conv_block.py
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 |
|
__call__
¤
__call__(
num_spatial_dims: int,
in_channels: int,
out_channels: int,
*,
activation: Callable,
boundary_mode: Literal[
"periodic", "dirichlet", "neumann"
],
key: PRNGKeyArray
)
Source code in pdequinox/blocks/_classic_double_conv_block.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
pdequinox.blocks.ClassicResBlockFactory
¤
Bases: Module
Source code in pdequinox/blocks/_classic_res_block.py
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 |
|
__init__
¤
__init__(
kernel_size: int = 3,
*,
use_norm: bool = False,
num_groups: int = 1,
use_bias: bool = True,
zero_bias_init: bool = False
)
Factory for creating ClassicResBlock
instances.
Arguments:
kernel_size
: The size of the convolutional kernel. Default is3
.use_norm
: Whether to use group normalization. Default isTrue
.num_groups
: The number of groups to use for group normalization. Default is1
.use_bias
: Whether to use bias in the convolutional layers. Default isTrue
.zero_bias_init
: Whether to initialise the bias to zero. Default isFalse
.
Source code in pdequinox/blocks/_classic_res_block.py
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 |
|
__call__
¤
__call__(
num_spatial_dims: int,
in_channels: int,
out_channels: int,
*,
activation: Callable,
boundary_mode: Literal[
"periodic", "dirichlet", "neumann"
],
key: PRNGKeyArray
)
Source code in pdequinox/blocks/_classic_res_block.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
pdequinox.blocks.ModernResBlockFactory
¤
Bases: Module
Source code in pdequinox/blocks/_modern_res_block.py
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 |
|
__init__
¤
__init__(
kernel_size: int = 3,
*,
use_norm: bool = True,
num_groups: int = 1,
use_bias: bool = True,
zero_bias_init: bool = False
)
Factory for creating ModernResBlock
instances.
Arguments:
kernel_size
: The size of the convolutional kernel. Default is3
.use_norm
: Whether to use group normalization. Default isTrue
.num_groups
: The number of groups to use for group normalization. Default is1
.use_bias
: Whether to use bias in the convolutional layers. Default isTrue
.zero_bias_init
: Whether to initialise the bias to zero. Default isFalse
.
Source code in pdequinox/blocks/_modern_res_block.py
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 |
|
__call__
¤
__call__(
num_spatial_dims: int,
in_channels: int,
out_channels: int,
*,
activation: Callable,
boundary_mode: Literal[
"periodic", "dirichlet", "neumann"
],
key: PRNGKeyArray
)
Source code in pdequinox/blocks/_modern_res_block.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
pdequinox.blocks.ClassicSpectralBlockFactory
¤
Bases: BlockFactory
Source code in pdequinox/blocks/_classic_spectral_block.py
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 |
|
__init__
¤
__init__(
*,
num_modes: int = 8,
use_bias: bool = True,
zero_bias_init: bool = False
)
Factory for creating ClassicSpectralBlock
instances.
Arguments:
num_modes
: How many modes to consider in Fourier space. At max this can be N//2+1, with N being the number of spatial points. Think of it as the analogy of the kernel size.use_bias
: Whether to use a bias in the bypass convolution. DefaultTrue
.zero_bias_init
: Whether to initialise the bias to zero. Default isFalse
.
Source code in pdequinox/blocks/_classic_spectral_block.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
__call__
¤
__call__(
num_spatial_dims: int,
in_channels: int,
out_channels: int,
*,
activation: Callable,
boundary_mode: Literal[
"periodic", "dirichlet", "neumann"
],
key: PRNGKeyArray
)
Source code in pdequinox/blocks/_classic_spectral_block.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
pdequinox.blocks.DilatedResBlockFactory
¤
Bases: Module
Source code in pdequinox/blocks/_dilated_res_block.py
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 |
|
__init__
¤
__init__(
kernel_size: int = 3,
dilation_rates: tuple[int] = (1, 2, 4, 8, 4, 2, 1),
*,
use_norm: bool = True,
num_groups: int = 1,
use_bias: bool = True,
zero_bias_init: bool = False
)
Factory for creating DilatedResBlock
instances.
Arguments:
kernel_size
: The size of the convolutional kernel. Default is3
.dilation_rates
: A sequence of integers. Their length identifies the number of sequential convolutions performed. Each integer is the dilation performed at that convolution. Typically, this list follows the pattern of first increasing in dilation rate, and then decreasing again. Default is(1, 2, 4, 8, 4, 2, 1)
.use_norm
: Whether to use group normalization. Default isTrue
.num_groups
: The number of groups to use for group normalization. Default is1
.use_bias
: Whether to use bias in the convolutional layers. Default isTrue
.zero_bias_init
: Whether to initialise the bias to zero. Default isFalse
.
Source code in pdequinox/blocks/_dilated_res_block.py
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 |
|
__call__
¤
__call__(
num_spatial_dims: int,
in_channels: int,
out_channels: int,
*,
activation: Callable,
boundary_mode: Literal[
"periodic", "dirichlet", "neumann"
],
key: PRNGKeyArray
) -> DilatedResBlock
Source code in pdequinox/blocks/_dilated_res_block.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
pdequinox.blocks.LinearConvBlockFactory
¤
Bases: BlockFactory
Source code in pdequinox/blocks/_linear_conv_block.py
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 |
|
__init__
¤
__init__(*, kernel_size: int = 3, use_bias: bool = True)
Factory for creating LinearConvBlock
instances.
Arguments:
kernel_size
: The size of the convolutional kernel. Default is3
.use_bias
: Whether to use bias in the convolutional layers. Default isTrue
.
Source code in pdequinox/blocks/_linear_conv_block.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
__call__
¤
__call__(
num_spatial_dims: int,
in_channels: int,
out_channels: int,
*,
activation: Callable,
boundary_mode: Literal[
"periodic", "dirichlet", "neumann"
],
key: PRNGKeyArray
)
Source code in pdequinox/blocks/_linear_conv_block.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
pdequinox.blocks.LinearConvDownBlockFactory
¤
Bases: BlockFactory
Source code in pdequinox/blocks/_linear_conv_down_block.py
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 |
|
__init__
¤
__init__(
*,
kernel_size: int = 3,
factor: int = 2,
use_bias: bool = True
)
Factory for creating LinearConvDownBlock
instances.
Arguments:
kernel_size
: The size of the convolutional kernel. Default is3
.factor
: The downsampling factor. Default is2
. This will become the stride of the convolution.use_bias
: Whether to use bias after the convolution. Default isTrue
.
Source code in pdequinox/blocks/_linear_conv_down_block.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
__call__
¤
__call__(
num_spatial_dims: int,
in_channels: int,
out_channels: int,
*,
activation: Callable,
boundary_mode: Literal[
"periodic", "dirichlet", "neumann"
],
key: PRNGKeyArray
)
Source code in pdequinox/blocks/_linear_conv_down_block.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
pdequinox.blocks.LinearConvUpBlockFactory
¤
Bases: BlockFactory
Source code in pdequinox/blocks/_linear_conv_up_block.py
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 |
|
__init__
¤
__init__(
*,
kernel_size: int = 3,
factor: int = 2,
use_bias: bool = True,
output_padding: int = 1
)
Factory for creating LinearConvUpBlock
instances.
Arguments:
kernel_size
: The size of the convolutional kernel. Default is3
.factor
: The upsampling factor. Default is2
. This will become the stride of the transposed convolution. Set this to the same value as in a correspondingLinearConvDownBlockFactory
instance.use_bias
: Whether to use bias after the convolution. Default isTrue
.output_padding
: The amount of additional padding used by the transposed convolution. Use this to resolve the ambiguity that the result of an integer division withfactor
is not bijective. If you havefactor=2
and work with spatial dimensions divisible by2
, set this to1
. Default is1
.
Source code in pdequinox/blocks/_linear_conv_up_block.py
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 |
|
__call__
¤
__call__(
num_spatial_dims: int,
in_channels: int,
out_channels: int,
*,
activation: Callable,
boundary_mode: Literal[
"periodic", "dirichlet", "neumann"
],
key: PRNGKeyArray
)
Source code in pdequinox/blocks/_linear_conv_up_block.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
pdequinox.blocks.BlockFactory
¤
Bases: Module
, ABC
Source code in pdequinox/blocks/_base_block.py
12 13 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 |
|
__call__
abstractmethod
¤
__call__(
num_spatial_dims: int,
in_channels: int,
out_channels: int,
*,
activation: Callable,
boundary_mode: Literal[
"periodic", "dirichlet", "neumann"
],
key: PRNGKeyArray
) -> Block
Construct a block (= equinox.Module
)
Arguments:
num_spatial_dims
: The number of spatial dimensions. For example traditional, convolutions for image processing have this set to2
.in_channels
: The number of input channels.out_channels
: The number of output channels.activation
: The activation function to use. For examplejax.nn.relu
.boundary_mode
: The boundary mode to use. For example"periodic"
. (Keyword only argument.)key
: Ajax.random.PRNGKey
used to provide randomness for parameter initialisation. (Keyword only argument.): Additional keyword arguments to pass to the boundary mode constructor.
Source code in pdequinox/blocks/_base_block.py
13 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 |
|