gradient based saliency map 效果图

saliency map
模型和数据如下:

dataset fashion-mnist
initialize torch.nn.init.kaiming_uniform_
loss function torch.nn.CrossEntropyLoss
optimizer torch.optim.AdamW
network structure

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(
            in_channels=1,  out_channels=16, kernel_size=3,
            padding=1, padding_mode='zeros', stride=1, dilation=1,
            groups=1, bias=True,
        )
        self.conv2 = nn.Conv2d(
            in_channels=16, out_channels=32, kernel_size=3,
            padding=1, padding_mode='circular', stride=1, dilation=1,
            groups=4, bias=True,
        )
        self.conv3 = nn.Conv2d(
            in_channels=32, out_channels=128, kernel_size=3,
            padding=1, padding_mode='circular', stride=1, dilation=1,
            groups=4, bias=True,
        )
        # self.pool = nn.MaxPool2d(
        #     kernel_size=2, padding=0, stride=2, dilation=1,
        #     return_indices=False, ceil_mode=False,
        # )
        self.pool = nn.AvgPool2d(
            kernel_size=2, padding=0, stride=2,
            count_include_pad=True, ceil_mode=False,
        )
        self.fc1 = nn.Linear(128*3*3, 512)
        self.fc2 = nn.Linear(512, 256)
        self.fc3 = nn.Linear(256, 128)
        self.fc4 = nn.Linear(128, 64)
        self.fc5 = nn.Linear(64, 10)
        self.relu = nn.ReLU()
        self.dropout = nn.Dropout(p=0.6)
        
    def forward(self, x):
        x = x.view(x.size()[0], 1, 28, 28)
        # _ 1 28 28
        x = self.conv1(x)
        x = self.relu(x)
        x = self.pool(x)
        # _ 16 14 14
        x = self.conv2(x)
        x = self.relu(x)
        x = self.pool(x)
        x = self.dropout(x)
        # _ 32 7 7
        x = self.conv3(x)
        x = self.relu(x)
        x = self.pool(x)
        # _ 128 3 3
        x = x.view(x.size()[0], 128*3*3)
        x = self.fc1(x)
        x = self.relu(x)
        x = self.fc2(x)
        x = self.relu(x)
        x = self.dropout(x)
        x = self.fc3(x)
        x = self.relu(x)
        x = self.dropout(x)
        x = self.fc4(x)
        x = self.relu(x)
        x = self.dropout(x)
        x = self.fc5(x)
        x = self.relu(x)

        return x 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值