(self,
img_size=224,
patch_size=16,
stride=16,
depth=24,
embed_dim=192,
channels=3,
num_classes=1000,
ssm_cfg=None,
drop_rate=0.,
drop_path_rate=0.1,
norm_epsilon: float = 1e-5,
rms_norm: bool = False,
initializer_cfg=None,
fused_add_norm=False,
residual_in_fp32=False,
device=None,
dtype=None,
ft_seq_len=None,
pt_hw_seq_len=14,
if_bidirectional=False,
final_pool_type='none',
if_abs_pos_embed=False,
if_rope=False,
if_rope_residual=False,
flip_img_sequences_ratio=-1.,
if_bimamba=False,
bimamba_type="none",
if_cls_token=False,
if_devide_out=False,
init_layer_scale=None,
use_double_cls_token=False,
use_middle_cls_token=False,
START_flag=0,
**kwargs)
| 230 | |
| 231 | class VisionMamba(nn.Module): |
| 232 | def __init__(self, |
| 233 | img_size=224, |
| 234 | patch_size=16, |
| 235 | stride=16, |
| 236 | depth=24, |
| 237 | embed_dim=192, |
| 238 | channels=3, |
| 239 | num_classes=1000, |
| 240 | ssm_cfg=None, |
| 241 | drop_rate=0., |
| 242 | drop_path_rate=0.1, |
| 243 | norm_epsilon: float = 1e-5, |
| 244 | rms_norm: bool = False, |
| 245 | initializer_cfg=None, |
| 246 | fused_add_norm=False, |
| 247 | residual_in_fp32=False, |
| 248 | device=None, |
| 249 | dtype=None, |
| 250 | ft_seq_len=None, |
| 251 | pt_hw_seq_len=14, |
| 252 | if_bidirectional=False, |
| 253 | final_pool_type='none', |
| 254 | if_abs_pos_embed=False, |
| 255 | if_rope=False, |
| 256 | if_rope_residual=False, |
| 257 | flip_img_sequences_ratio=-1., |
| 258 | if_bimamba=False, |
| 259 | bimamba_type="none", |
| 260 | if_cls_token=False, |
| 261 | if_devide_out=False, |
| 262 | init_layer_scale=None, |
| 263 | use_double_cls_token=False, |
| 264 | use_middle_cls_token=False, |
| 265 | START_flag=0, |
| 266 | **kwargs): |
| 267 | factory_kwargs = {"device": device, "dtype": dtype} |
| 268 | # add factory_kwargs into kwargs |
| 269 | kwargs.update(factory_kwargs) |
| 270 | super().__init__() |
| 271 | self.residual_in_fp32 = residual_in_fp32 # True |
| 272 | self.fused_add_norm = fused_add_norm # True |
| 273 | self.if_bidirectional = if_bidirectional # False |
| 274 | self.final_pool_type = final_pool_type # 'mean' |
| 275 | self.if_abs_pos_embed = if_abs_pos_embed # True |
| 276 | self.if_rope = if_rope # False |
| 277 | self.if_rope_residual = if_rope_residual # False |
| 278 | self.flip_img_sequences_ratio = flip_img_sequences_ratio |
| 279 | self.if_cls_token = if_cls_token # True |
| 280 | self.use_double_cls_token = use_double_cls_token # False |
| 281 | self.use_middle_cls_token = use_middle_cls_token # True |
| 282 | self.num_tokens = 1 if if_cls_token else 0 # 1 |
| 283 | |
| 284 | # rms_norm=True, bimamba_type="v2", if_devide_out=True, |
| 285 | |
| 286 | |
| 287 | # pretrain parameters |
| 288 | self.num_classes = num_classes |
| 289 | self.d_model = self.num_features = self.embed_dim = embed_dim # num_features for consistency with other models, 192 / 384 |
nothing calls this directly
no test coverage detected