cct
CCT Model API
This module provides utility functions to generate Compact Convolutional Transformer (CCT) models.
Classes:
-
CCTParams
–CCT parameters
-
CCTModel
–Helper class to generate model from parameters
-
StochasticDepth
–StochasticDepth
Functions:
-
cct_tokenizer_block
–CCT tokenizer block
-
cct_mlp
–CCT MPL block
-
cct_layer
–Generate Compact Convolutional Transformer model (CCT)
Classes
CCTParams
StochasticDepth
StochasticDepth
Stochastic Depth Args: drop_prop (float): Drop probability
Source code in neuralspot_edge/models/cct.py
Functions
call
Forward pass
Parameters:
-
inputs
(KerasTensor
) –Input tensor
Returns:
-
KerasTensor
–keras.KerasTensor: Output tensor
Source code in neuralspot_edge/models/cct.py
CCTModel
Helper class to generate model from parameters
Functions
layer_from_params
staticmethod
Create layer from parameters
Source code in neuralspot_edge/models/cct.py
model_from_params
staticmethod
Create model from parameters
Source code in neuralspot_edge/models/cct.py
Functions
cct_tokenizer_block
cct_tokenizer_block(kernel_size: int = 3, stride: int = 1, padding: int = 1, pooling_kernel_size: int = 3, pooling_stride: int = 2, num_conv_layers: int = 2, filter_sizes: tuple[int, int] = (64, 128)) -> Callable[[keras.KerasTensor], keras.KerasTensor]
CCT tokenizer block
Parameters:
-
kernel_size
(int
, default:3
) –Kernel size. Defaults to 3.
-
stride
(int
, default:1
) –Stride length. Defaults to 1.
-
padding
(int
, default:1
) –Padding. Defaults to 1.
-
pooling_kernel_size
(int
, default:3
) –Pooling kernel size. Defaults to 3.
-
pooling_stride
(int
, default:2
) –Pooling stride. Defaults to 2.
-
num_conv_layers
(int
, default:2
) –Number of conv layers. Defaults to 2.
-
filter_sizes
(tuple[int]
, default:(64, 128)
) –Number of filters per layer. Defaults to (64, 128).
Source code in neuralspot_edge/models/cct.py
cct_mlp
CCT MPL block
Parameters:
-
x
(KerasTensor
) –Input tensor
-
hidden_units
(list[int]
) –Number of hidden units
-
dropout_rate
(float
) –Dropout rate
Returns:
-
KerasTensor
–keras.KerasTensor: Output tensor
Source code in neuralspot_edge/models/cct.py
cct_layer
Generate Compact Convolutional Transformer model (CCT)
Parameters:
-
x
(KerasTensor
) –Input tensor
-
params
(CCTParams
) –Model parameters
-
num_classes
(int
) –Number of classes
Returns:
-
KerasTensor
–keras.KerasTensor: Output tensor