data
CSPNetConfig
extends
ModelConfigCSPNetConfig(num_classes: int = 1000, in_channels: int = 3, stem_out_chs: int = 64, stem_kernel: int = 7, stem_stride: int = 2, stem_pool: str = 'max', depths: tuple[int, ...] = (3, 3, 5, 2), out_chs: tuple[int, ...] = (128, 256, 512, 1024), strides: tuple[int, ...] = (1, 2, 2, 2), groups: tuple[int, ...] = (1, 1, 1, 1), expand_ratio: tuple[float, ...] = (2.0, 2.0, 2.0, 2.0), bottle_ratio: tuple[float, ...] = (0.5, 0.5, 0.5, 0.5), block_ratio: tuple[float, ...] = (1.0, 1.0, 1.0, 1.0), cross_linear: tuple[bool, ...] = (True, True, True, True), down_growth: tuple[bool, ...] = (False, False, False, False), block_type: tuple[str, ...] = ('bottle', 'bottle', 'bottle', 'bottle'), dropout: float = 0.0)Generic configuration for every paper-cited CSPNet variant.
Parameters
num_classesint= 1000No description.
in_channelsint= 3No description.
stem_out_chsint= 64Output channels of the stem.
64 for the CSPResNet
variants (7×7 stride-4 + max-pool), 32 for CSPDarknet-53
(3×3 stride-1, no pool).stem_kernelint= 7Kernel size of the stem convolution.
stem_strideint= 4Stride of the stem (post-stem max-pool yields a further /2 for
CSPResNet, none for CSPDarknet).
stem_poolstr= "max""max" (CSPResNet line) or "" (CSPDarknet — no pool).block_typestr= "bottle"Per-stage block flavour:
"bottle" = residual bottleneck
(CSPResNet / CSPResNeXt), "dark" = Darknet block
(CSPDarknet).stage_layoutstr= "cross""cross" = CSP-wrapped (CrossStage), "dark" = plain
sequential (DarkStage).depthstuple of int= (3, 3, 5, 2)Block counts per stage.
out_chstuple of int= (128, 256, 512, 1024)Per-stage output channel widths.
stridestuple of int= (1, 2, 2, 2)Per-stage stride (1 = no downsample, 2 = halve spatial).
groupsint= 1Per-bottleneck grouped-conv count (CSPResNeXt-50 uses 32).
expand_ratiofloat= 2.0How wide
conv_exp is relative to the stage's input.bottle_ratiofloat= 0.5Bottleneck reduction inside each block.
block_ratiofloat= 1.0Branch-output reduction inside CrossStage transitions.
cross_linearbool= TrueWhether the
conv_exp of CrossStage skips its activation
(paper-cited variants do skip).down_growthbool= FalseCSPDarknet only — whether the down-conv at each stage already
applies the channel expansion.
dropoutfloat= 0.0Head dropout probability.
Used by 3
Constructors
1dunder
__init__
→None__init__(num_classes: int = 1000, in_channels: int = 3, stem_out_chs: int = 64, stem_kernel: int = 7, stem_stride: int = 2, stem_pool: str = 'max', depths: tuple[int, ...] = (3, 3, 5, 2), out_chs: tuple[int, ...] = (128, 256, 512, 1024), strides: tuple[int, ...] = (1, 2, 2, 2), groups: tuple[int, ...] = (1, 1, 1, 1), expand_ratio: tuple[float, ...] = (2.0, 2.0, 2.0, 2.0), bottle_ratio: tuple[float, ...] = (0.5, 0.5, 0.5, 0.5), block_ratio: tuple[float, ...] = (1.0, 1.0, 1.0, 1.0), cross_linear: tuple[bool, ...] = (True, True, True, True), down_growth: tuple[bool, ...] = (False, False, False, False), block_type: tuple[str, ...] = ('bottle', 'bottle', 'bottle', 'bottle'), dropout: float = 0.0)