alibi_detect.models.resnet module¶
-
class
alibi_detect.models.resnet.
LearningRateBatchScheduler
(schedule, batch_size, steps_per_epoch)[source]¶ Bases:
tensorflow.keras.callbacks.Callback
-
alibi_detect.models.resnet.
conv_block
(x_in, filters, kernel_size, stage, block, strides=(2, 2), l2_regularisation=True)[source]¶ Conv block in ResNet with a parameterised skip connection to reduce the width and height controlled by the strides.
- Parameters
x_in (tensorflow.Tensor) – Input Tensor.
filters (
Tuple
[int
,int
]) – Number of filters for each of the 2 conv layers.kernel_size (
Union
[int
,list
,Tuple
[int
]]) – Kernel size for the conv layers.stage (
int
) – Stage of the block in the ResNet.block (
str
) – Block within a stage in the ResNet.strides (
Tuple
[int
,int
]) – Stride size applied to reduce the image size.l2_regularisation (
bool
) – Whether to apply L2 regularisation.
- Return type
tensorflow.Tensor
- Returns
Output Tensor of the conv block.
-
alibi_detect.models.resnet.
identity_block
(x_in, filters, kernel_size, stage, block, l2_regularisation=True)[source]¶ Identity block in ResNet.
- Parameters
x_in (tensorflow.Tensor) – Input Tensor.
filters (
Tuple
[int
,int
]) – Number of filters for each of the 2 conv layers.kernel_size (
Union
[int
,list
,Tuple
[int
]]) – Kernel size for the conv layers.stage (
int
) – Stage of the block in the ResNet.block (
str
) – Block within a stage in the ResNet.l2_regularisation (
bool
) – Whether to apply L2 regularisation.
- Return type
tensorflow.Tensor
- Returns
Output Tensor of the identity block.
-
alibi_detect.models.resnet.
l2_regulariser
(l2_regularisation=True)[source]¶ Apply L2 regularisation to kernel.
- Parameters
l2_regularisation (
bool
) – Whether to apply L2 regularisation.- Returns
Kernel regularisation.
-
alibi_detect.models.resnet.
learning_rate_schedule
(current_epoch, current_batch, batches_per_epoch, batch_size)[source]¶ Linear learning rate scaling and learning rate decay at specified epochs.
-
alibi_detect.models.resnet.
resnet
(num_blocks, classes=10, input_shape=(32, 32, 3))[source]¶ Define ResNet.
-
alibi_detect.models.resnet.
resnet_block
(x_in, size, filters, kernel_size, stage, strides=(2, 2), l2_regularisation=True)[source]¶ Block in ResNet combining a conv block with identity blocks.
- Parameters
x_in (tensorflow.Tensor) – Input Tensor.
size (
int
) – The ResNet block consists of 1 conv block and size-1 identity blocks.filters (
Tuple
[int
,int
]) – Number of filters for each of the conv layers.kernel_size (
Union
[int
,list
,Tuple
[int
]]) – Kernel size for the conv layers.stage (
int
) – Stage of the block in the ResNet.strides (
Tuple
[int
,int
]) – Stride size applied to reduce the image size.l2_regularisation (
bool
) – Whether to apply L2 regularisation.
- Return type
tensorflow.Tensor
- Returns
Output Tensor of the conv block.