x = l.blocks(x)
y = l.downsample(x)
return x, y
x = self.patch_embed(x)
outs = []
# 对应Encoder
for i, layer in enumerate(self.layers):
o, x = layer_forward(layer, x) # (B, H, W, C)
if i in self.out_indices:
norm_layer = getattr(self, f"outnorm{i}")
# 在Downsample后面添加对应的4个NormLayer
# 最后只用到了结果o?
out = norm_layer(o)
if not self.channel_first:
out = out.permute(0, 3, 1, 2).contiguous()
outs.append(out)
if len(self.out_indices) == 0:
return x
return outs`
Mamba_backbone.py这个文件应该是Encoder模块,它里面的forward函数layer_forward有两个返回值分别为o和x,为什么最后只应用了经过了VSSBlock的o作为out,而不是x,而且为什么是先通过VSSBlock,不是应该先下采样吗? `def forward(self, x): def layer_forward(l, x):
这里是先应用blocks, 再应用downsample