MCPcopy Create free account
hub / github.com/lingeringlight/START / VisionMamba

Class VisionMamba

models_mamba.py:231–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229
230
231class 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

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…