我什么时候使用乘法和加法

数据挖掘 神经网络 喀拉斯 卷积神经网络
2022-03-07 18:29:04

我想通过功能了解kerasAddMultiply在 keras 中的效果。愚蠢的思维方式是它们旨在添加和乘以 keras 张量。我想知道它们什么时候使用。例如,从这里查看下面的代码。为什么使用Multiplyinspatial_squeeze_excite_block和为什么使用Addin channel_spatial_squeeze_excite我们可以在这些功能中切换Add和吗?Multiply为什么不?

def spatial_squeeze_excite_block(input):
    ''' Create a spatial squeeze-excite block
    Args:
        input: input tensor
    Returns: a keras tensor
    References
    -   [Concurrent Spatial and Channel Squeeze & Excitation in Fully Convolutional Networks](https://arxiv.org/abs/1803.02579)
    '''

    se = Conv2D(1, (1, 1), activation='sigmoid', use_bias=False,
                kernel_initializer='he_normal')(input)

    x = Multiply([input, se])
    return x


def channel_spatial_squeeze_excite(input, ratio=16):
    ''' Create a spatial squeeze-excite block
    Args:
        input: input tensor
        filters: number of output filters
    Returns: a keras tensor
    References
    -   [Squeeze and Excitation Networks](https://arxiv.org/abs/1709.01507)
    -   [Concurrent Spatial and Channel Squeeze & Excitation in Fully Convolutional Networks](https://arxiv.org/abs/1803.02579)
    '''

    cse = squeeze_excite_block(input, ratio)
    sse = spatial_squeeze_excite_block(input)

    x = Add([cse, sse])
    return x
1个回答

它们是这样定义的。看看文档字符串中引用的论文。sse 在等式中定义。3,scSE在2.3的正文中定义。