首页 > 解决方案 > 卷积神经网络中的聚合和连接有什么区别?

问题描述

当我阅读一些关于 CNN 的经典论文时,如 Inception family、ResNet、VGGnet 等,我注意到术语concatenationsummationaggregation,这让我很困惑(summation 对我来说很容易理解)。有人能告诉我它们之间有什么区别吗?也许以更具体的方式,例如使用示例来说明维度和表示能力的差异。

标签: deep-learningconv-neural-networkterminology

解决方案


  • Concatenation generally consists of taking 2 or more output tensors from different network layers and concatenating them along the channel dimension
  • Aggregation consists in taking 2 or more output tensors from different network layers and applying a chosen multivariate function on them to aggregate the results
  • Summation is a special case of aggregation where the function is a sum

This implies that we lose information by doing aggregation. On the other hand, concatenation will make it possible to retain information at the cost of greater memory usage.

E.g. in PyTorch:

import torch

batch_size = 8
num_channels = 3
h, w = 512, 512
t1 = torch.rand(batch_size, num_channels, h, w) # A tensor with shape [8, 3, 512, 512]
t2 = torch.rand(batch_size, num_channels, h, w) # A tensor with shape [8, 3, 512, 512]

torch.cat((t1, t2), dim=1) # A tensor with shape [8, 6, 512, 512]
t1 + t2 # A tensor with shape [8, 3, 512, 512]

推荐阅读