欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

msfn理解

程序员文章站 2024-03-15 10:35:05
...

msfn理解
1~8的组合形式:

0: 4
1: 8
2: 16
3: 32

spatial aware pooling
sap: [2, 4, 8, 16, 32]

0_sap: [4, 8, 16, 32, 64, 128]
1_sap: [8, 16, 32, 64, 128, 256]
2_sap: [16, 32, 64, 128, 256, 512]
3_sap: [32, 64, 128, 256, 512, 1024]


concat1_8 = [s_0_8, s_1_8]
concat2_16 = [s_0_16, s_1_16, s_2_16]
concat3_32 = [s_0_32, s_1_32, s_2_32]
concat4_64 = [s_0_64, s_1_64, s_2_64]
concat5_128 = [s_0_128, s_1_128, s_2_128]
concat6_256 = [s_1_256, s_2_256, s_3_256]
concat7_512 = [s_2_512, s_3_512]
concat8_1024 = [s_3_1024]
import torch

j_list = [1, 2, 3, 4, 5]
k_list = []  # 核大小
s_list = []  # 步长
for j in j_list:
    s = 2 ** j
    s_list.append(s)
    k = 2 * s + 1

    k_list.append(k)

print(s_list, k_list)

input_tensor = torch.randn((2, 3, 256, 256)).requires_grad_(True)

pool_0 = torch.nn.MaxPool2d(kernel_size=k_list[0], stride=s_list[0])
pool_1 = torch.nn.MaxPool2d(kernel_size=k_list[1], stride=s_list[1])
pool_2 = torch.nn.MaxPool2d(kernel_size=k_list[2], stride=s_list[2])
pool_3 = torch.nn.MaxPool2d(kernel_size=k_list[3], stride=s_list[3])
pool_4 = torch.nn.MaxPool2d(kernel_size=k_list[4], stride=s_list[4])

#SPA的 6个
no_pool = input_tensor  # torch.Size([2, 3, 512, 1024])
pool_0_out = pool_0(input_tensor)  # torch.Size([2, 3, 254, 510]) 2
pool_1_out = pool_1(input_tensor)  # torch.Size([2, 3, 126, 254]) 4
pool_2_out = pool_2(input_tensor)  # torch.Size([2, 3, 62, 126]) 8
pool_3_out = pool_3(input_tensor)  # torch.Size([2, 3, 30, 62]) 16
pool_4_out = pool_4(input_tensor)  # torch.Size([2, 3, 14, 30]) 32
print(pool_4_out.size())
相关标签: 语义分割