unext
U-NeXt
Overview
U-NeXt is a modification of U-Net that utilizes techniques from ResNeXt and EfficientNetV2. During the encoding phase, mbconv blocks are used to efficiently process the input.
Classes:
-
UNextParams
–U-NeXt parameters
-
UNextModel
–Helper class to generate
Functions:
-
unext_block
–Create U-NeXt block
-
se_block
–Squeeze and excite block
-
norm_layer
–Normalization layer
-
unext_core
–Create U-NeXt core
-
unext_layer
–Create U-NeXt layer
Additions
The U-NeXt architecture has been modified to allow the following:
- MBConv blocks used in the encoding phase.
- Squeeze and excitation (SE) blocks added within blocks.
Classes
UNextBlockParams
UNext block parameters
Attributes:
-
filters
(int
) –Number of filters
-
depth
(int
) –Layer depth
-
ddepth
(int | None
) –Layer decoder depth
-
kernel
(int | tuple[int, int]
) –Kernel size
-
pool
(int | tuple[int, int]
) –Pool size
-
strides
(int | tuple[int, int]
) –Stride size
-
skip
(bool
) –Add skip connection
-
expand_ratio
(float
) –Expansion ratio
-
se_ratio
(float
) –Squeeze and excite ratio
-
dropout
(float | None
) –Dropout rate
-
norm
(Literal['batch', 'layer'] | None
) –Normalization type
UNextParams
UNextModel
Helper class to generate model from parameters
Functions
layer_from_params
staticmethod
Create layer from parameters
Source code in neuralspot_edge/models/unext.py
model_from_params
staticmethod
Create model from parameters
Source code in neuralspot_edge/models/unext.py
Functions
se_block
Squeeze and excite block
Source code in neuralspot_edge/models/unext.py
norm_layer
Normalization layer
Parameters:
Returns:
-
Layer
–keras.Layer: Layer
Source code in neuralspot_edge/models/unext.py
unext_block
unext_block(output_filters: int, expand_ratio: float = 1, kernel_size: int | tuple[int, int] = 3, strides: int | tuple[int, int] = 1, se_ratio: float = 4, dropout: float | None = 0, norm: Literal['batch', 'layer'] | None = 'batch', name: str | None = None) -> keras.Layer
Create UNext block
Source code in neuralspot_edge/models/unext.py
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 |
|
unext_core
Create UNext TF functional core
Parameters:
-
x
(KerasTensor
) –Input tensor
-
params
(UNextParams
) –Model parameters.
Returns:
-
KerasTensor
–keras.KerasTensor: Output tensor
Source code in neuralspot_edge/models/unext.py
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 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
|
unext_layer
unext_layer(inputs: keras.KerasTensor, params: UNextParams, num_classes: int | None = None) -> keras.KerasTensor
Create UNext TF functional model
Parameters:
-
inputs
(KerasTensor
) –Input tensor
-
params
(UNextParams
) –Model parameters.
-
num_classes
(int
, default:None
) –Number of classes.
Returns:
-
KerasTensor
–keras.KerasTensor: Output tensor