regnet
RegNet Model API
This module provides utility functions to generate RegNet models.
Fore more information, please refer to the following paper: https://arxiv.org/abs/2101.00590
Classes:
-
RegNetBlockParam
–RegNet block parameters
-
RegNetParams
–RegNet parameters
-
RegNetModel
–Helper class to generate RegNet models
Functions:
-
regnet_core
–RegNet core
-
regnet_layer
–Generate RegNet model
Classes
RegNetBlockParam
RegNet block parameters
Attributes:
-
filters
(int
) –Number of filters
-
depth
(int
) –Layer depth
-
group_width
(int
) –Group width
-
kernel_size
(int | tuple[int, int]
) –Kernel size
-
strides
(int | tuple[int, int]
) –Stride size
-
se_ratio
(float
) –Squeeze Excite ratio
-
droprate
(float
) –Drop rate
-
activation
(str
) –Activation function
RegNetParams
RegNet parameters
Attributes:
blocks (list[RegNetBlockParam]): RegNet blocks
input_filters (int): Input filters
input_strides (int | tuple[int, int]): Input stride
input_activation (str): Input activation
output_filters (int): Output filters
block_style (Literal["y", "z"]): Block style
include_top (bool): Include top
output_activation (str | None): Output activation
dropout (float): Dropout rate
name (str): Model name
RegNetModel
Helper class to generate model from parameters
Functions
layer_from_params
staticmethod
Create layer from parameters
Source code in neuralspot_edge/models/regnet.py
model_from_params
staticmethod
Create model from parameters
Source code in neuralspot_edge/models/regnet.py
Functions
yblock
yblock(output_filters: int = 0, group_width: int = 0, kernel_size: int | tuple[int, int] = 3, strides: int | tuple[int, int] = 1, se_ratio: float = 4, activation: str = 'relu6', name: str | None = None) -> Callable[[keras.KerasTensor], keras.KerasTensor]
RegNet Y-Block
Parameters:
-
output_filters
(int
, default:0
) –Number of output filters. Defaults to 0.
-
group_width
(int
, default:0
) –Group width. Defaults to 0.
-
kernel_size
(int | tuple[int, int]
, default:3
) –Kernel size. Defaults to 3.
-
strides
(int | tuple[int, int]
, default:1
) –Stride length. Defaults to 1.
-
se_ratio
(float
, default:4
) –SE ratio. Defaults to 4.
-
activation
(str
, default:'relu6'
) –Activation function. Defaults to "relu6".
-
name
(str | None
, default:None
) –Block name. Defaults to None.
Returns:
-
Callable[[KerasTensor], KerasTensor]
–Callable[[keras.KerasTensor], keras.KerasTensor]: Functional layer
Source code in neuralspot_edge/models/regnet.py
zblock
zblock(output_filters: int = 0, group_width: int = 0, kernel_size: int | tuple[int, int] = 3, strides: int | tuple[int, int] = 1, se_ratio: float = 4, activation: str = 'relu6', name: str | None = None) -> Callable[[keras.KerasTensor], keras.KerasTensor]
RegNet X-Block
Parameters:
-
output_filters
(int
, default:0
) –Number of output filters. Defaults to 0.
-
group_width
(int
, default:0
) –Group width. Defaults to 0.
-
kernel_size
(int | tuple[int, int]
, default:3
) –Kernel size. Defaults to 3.
-
strides
(int | tuple[int, int]
, default:1
) –Stride length. Defaults to 1.
-
se_ratio
(float
, default:4
) –SE ratio. Defaults to 4.
-
activation
(str
, default:'relu6'
) –Activation function. Defaults to "relu6".
-
name
(str | None
, default:None
) –Block name. Defaults to None.
Returns:
-
Callable[[KerasTensor], KerasTensor]
–Callable[[keras.KerasTensor], keras.KerasTensor]: Functional layer
Source code in neuralspot_edge/models/regnet.py
regnet_core
regnet_core(blocks: list[RegNetBlockParam], block_style: Literal['y', 'z'] = 'y') -> Callable[[keras.KerasTensor], keras.KerasTensor]
RegNet core
Parameters:
-
blocks
(list[RegNetBlockParam]
) –Block params
-
block_style
(float
, default:'y'
) –Block style. Defaults to 'y'.
Returns:
-
Callable[[KerasTensor], KerasTensor]
–Callable[[keras.KerasTensor], keras.KerasTensor]: Core
Source code in neuralspot_edge/models/regnet.py
regnet_layer
regnet_layer(x: keras.KerasTensor, params: RegNetParams, num_classes: int | None = None) -> keras.KerasTensor
Create RegNet TF functional model
Parameters:
-
x
(KerasTensor
) –Input tensor
-
params
(RegNetParams
) –Model parameters.
-
num_classes
(int
, default:None
) –Number of classes.
Returns:
-
KerasTensor
–keras.KerasTensor: Output tensor