如何实现单跳连接?

问题描述 投票:0回答:1

我的意思并不是整个层到另一个整个层的跳跃连接,我的意思是某个层 L1 中的单个神经元到某个层 L2 中的另一个神经元的单个连接。

deep-learning pytorch
1个回答
0
投票

我想,你可以选择相应的张量通道。从经典的ResNet开始, https://github.com/pytorch/vision/blob/a9a8220e0bcb4ce66a733f8c03a1c2f6c68d22cb/torchvision/models/resnet.py#L56-L72

def forward(self, x):
    identity = x

    out = self.conv1(x)
    ...
    
    if self.downsample is not None:
        identity = self.downsample(x)

    out += identity
    ...

将更改为

    # NCHW layout assumed
    out[:, C2,:,:] += identity[:, C1,:,:]

这里 C2 是所需目标通道(神经元)的索引,C1 - 源通道。

© www.soinside.com 2019 - 2024. All rights reserved.