每日Attention学习3——Cross-level Feature Fusion

模块出处

[link] [code] [PR 23] Cross-level Feature Aggregation Network for Polyp Segmentation


模块名称

Cross-level Feature Fusion (CFF)


模块作用

双级特征融合


模块结构

模块代码
python 复制代码
import torch
import torch.nn as nn


class BasicConv2d(nn.Module):
    def __init__(self, in_planes, out_planes, kernel_size, stride=1, padding=0, dilation=1):
        super(BasicConv2d, self).__init__()
        self.conv = nn.Conv2d(in_planes, out_planes,
                              kernel_size=kernel_size, stride=stride,
                              padding=padding, dilation=dilation, bias=False)
        self.bn = nn.BatchNorm2d(out_planes)
        self.relu = nn.ReLU(inplace=True)

    def forward(self, x):
        x = self.conv(x)
        x = self.bn(x)
        return x
    

class CFF(nn.Module):
    def __init__(self, in_channel1, in_channel2, out_channel):
        self.init__ = super(CFF, self).__init__()
        act_fn         = nn.ReLU(inplace=True)
                
        self.layer0    = BasicConv2d(in_channel1, out_channel // 2, 1)
        self.layer1    = BasicConv2d(in_channel2, out_channel // 2, 1)
        
        self.layer3_1  = nn.Sequential(nn.Conv2d(out_channel, out_channel // 2, kernel_size=3, stride=1, padding=1),  nn.BatchNorm2d(out_channel // 2),act_fn)
        self.layer3_2  = nn.Sequential(nn.Conv2d(out_channel, out_channel // 2, kernel_size=3, stride=1, padding=1),  nn.BatchNorm2d(out_channel // 2),act_fn)
        
        self.layer5_1  = nn.Sequential(nn.Conv2d(out_channel, out_channel // 2, kernel_size=5, stride=1, padding=2),  nn.BatchNorm2d(out_channel // 2),act_fn)
        self.layer5_2  = nn.Sequential(nn.Conv2d(out_channel, out_channel // 2, kernel_size=5, stride=1, padding=2),  nn.BatchNorm2d(out_channel // 2),act_fn)
        
        self.layer_out = nn.Sequential(nn.Conv2d(out_channel // 2, out_channel, kernel_size=3, stride=1, padding=1), nn.BatchNorm2d(out_channel),act_fn)


    def forward(self, x0, x1):
        x0_1  = self.layer0(x0)
        x1_1  = self.layer1(x1)
        x_3_1 = self.layer3_1(torch.cat((x0_1,  x1_1),  dim=1))    
        x_5_1 = self.layer5_1(torch.cat((x1_1,  x0_1),  dim=1))
        x_3_2 = self.layer3_2(torch.cat((x_3_1, x_5_1), dim=1))
        x_5_2 = self.layer5_2(torch.cat((x_5_1, x_3_1), dim=1))
        out   = self.layer_out(x0_1 + x1_1 + torch.mul(x_3_2, x_5_2))
        return out
    
if __name__ == '__main__':
    x1 = torch.randn([1, 256, 16, 16])
    x2 = torch.randn([1, 512, 16, 16])
    cff = CFF(in_channel1=256, in_channel2=512, out_channel=64)
    out = cff(x1, x2)
    print(out.shape)  # 1, 64, 16, 16

原文表述

利用特征提取网络可以获得不同分辨率的多级特征。因此,有效整合多级特征非常重要,这可以提高不同尺度特征的表示能力。因此,我们提出了一个 CFF模块来融合相邻的两个特征,然后将其输入分割网络。

相关推荐
三木今天学习了嘛6 小时前
【VLA & Markov】VLA 架构和构建模块 与 Markov 带来的时序思考
论文阅读
依夏c7 小时前
[论文笔记•(多智能体)]LLMs Can Simulate Standardized Patients via Agent Coevolution
论文阅读·论文笔记
wzx_Eleven8 小时前
【论文阅读】AAAI 2025 | 面向精确分割式联邦学习的多模型聚合与知识重放
论文阅读·人工智能·机器学习
Zack_Liu8 小时前
LSS论文阅读
论文阅读·人工智能·目标跟踪
何如千泷8 小时前
【论文阅读】SelfReg-UNet: Self-Regularized UNet for Medical Image Segmentation
论文阅读
张较瘦_8 小时前
[论文阅读] AI + Debug | 基于大语言模型的GitHub故障复现测试用例生成方法解析
论文阅读·人工智能·语言模型
Small___ming8 小时前
【论文笔记】扩散模型——如何通俗理解传统概率模型的核心矛盾
论文阅读·人工智能·扩散模型·生成式人工智能
张较瘦_8 小时前
[论文阅读] AI + 软件工程 | 从“能用”到“耐用”:LLM生成软件的老化陷阱与研究突破
论文阅读·人工智能·软件工程
番茄寿司2 天前
基于LSTM的多变量时间序列预测创新路径
论文阅读·深度学习·计算机网络·机器学习·lstm
森诺Alyson2 天前
前沿技术借鉴研讨-2025.10.28(超声数据)
论文阅读·经验分享·深度学习·论文笔记·论文讨论