【问题标题】:What is the output dimension in the googlenet after the concat layer?concat 层后 googlenet 中的输出维度是多少?
【发布时间】:2017-02-12 07:25:53
【问题描述】:

查看 googlenet 的 prototxt 时,发现初始层的末尾有一个 concat 层,它需要几个底部输入。

例如:

layer {
  name: "inception_3a/output"
  type: "Concat"
  bottom: "inception_3a/1x1"
  bottom: "inception_3a/3x3"
  bottom: "inception_3a/5x5"
  bottom: "inception_3a/pool_proj"
  top: "inception_3a/output"
}

可以看出,有一个 1x1 的卷积层,一个 3x3 的卷积层,一个 5x5 的卷积层,最后是一个池化层。这些层描述如下:

layer {
  name: "inception_3a/1x1"
  type: "Convolution"
  bottom: "pool2/3x3_s2"
  top: "inception_3a/1x1"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 64
    kernel_size: 1
    weight_filler {
      type: "xavier"
      std: 0.03
    }
    bias_filler {
      type: "constant"
      value: 0.2
    }
  }
}
layer {
  name: "inception_3a/relu_1x1"
  type: "ReLU"
  bottom: "inception_3a/1x1"
  top: "inception_3a/1x1"
}
layer {
  name: "inception_3a/3x3_reduce"
  type: "Convolution"
  bottom: "pool2/3x3_s2"
  top: "inception_3a/3x3_reduce"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 96
    kernel_size: 1
    weight_filler {
      type: "xavier"
      std: 0.09
    }
    bias_filler {
      type: "constant"
      value: 0.2
    }
  }
}
layer {
  name: "inception_3a/relu_3x3_reduce"
  type: "ReLU"
  bottom: "inception_3a/3x3_reduce"
  top: "inception_3a/3x3_reduce"
}
layer {
  name: "inception_3a/3x3"
  type: "Convolution"
  bottom: "inception_3a/3x3_reduce"
  top: "inception_3a/3x3"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 128
    pad: 1
    kernel_size: 3
    weight_filler {
      type: "xavier"
      std: 0.03
    }
    bias_filler {
      type: "constant"
      value: 0.2
    }
  }
}
layer {
  name: "inception_3a/relu_3x3"
  type: "ReLU"
  bottom: "inception_3a/3x3"
  top: "inception_3a/3x3"
}
layer {
  name: "inception_3a/5x5_reduce"
  type: "Convolution"
  bottom: "pool2/3x3_s2"
  top: "inception_3a/5x5_reduce"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 16
    kernel_size: 1
    weight_filler {
      type: "xavier"
      std: 0.2
    }
    bias_filler {
      type: "constant"
      value: 0.2
    }
  }
}
layer {
  name: "inception_3a/relu_5x5_reduce"
  type: "ReLU"
  bottom: "inception_3a/5x5_reduce"
  top: "inception_3a/5x5_reduce"
}
layer {
  name: "inception_3a/5x5"
  type: "Convolution"
  bottom: "inception_3a/5x5_reduce"
  top: "inception_3a/5x5"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 32
    pad: 2
    kernel_size: 5
    weight_filler {
      type: "xavier"
      std: 0.03
    }
    bias_filler {
      type: "constant"
      value: 0.2
    }
  }
}
layer {
  name: "inception_3a/relu_5x5"
  type: "ReLU"
  bottom: "inception_3a/5x5"
  top: "inception_3a/5x5"
}
layer {
  name: "inception_3a/pool"
  type: "Pooling"
  bottom: "pool2/3x3_s2"
  top: "inception_3a/pool"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 1
    pad: 1
  }
}
layer {
  name: "inception_3a/pool_proj"
  type: "Convolution"
  bottom: "inception_3a/pool"
  top: "inception_3a/pool_proj"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 32
    kernel_size: 1
    weight_filler {
      type: "xavier"
      std: 0.1
    }
    bias_filler {
      type: "constant"
      value: 0.2
    }
  }
}

可以看出,这些有不同的输出数量和不同的过滤器大小,无论如何concat层的文档如下:

输入:

n_i * c_i * h * w for each input blob i from 1 to K.

输出:

如果axis = 0:(n_1 + n_2 + ... + n_K) * c_1 * h * w,并且所有输入c_i 应该是一样的。

如果axis = 1:n_1 * (c_1 + c_2 + ... + c_K) * h * w,并且所有输入n_i都应该相同。

首先,我不确定默认值是什么,其次我不确定哪个维度将具有输出 Volume,因为宽度和高度应该保持不变,但所有 thre 卷积层都会产生不同的输出。任何指针将不胜感激

【问题讨论】:

    标签: deep-learning caffe concat


    【解决方案1】:

    'Concat' 轴的默认值为 1,因此通过通道维度连接。为了做到这一点,所有连接的层都应该具有相同的高度和宽度。查看日志,尺寸为(假设批量大小为 32):

    inception_3a/1x1 -> [32, 64, 28, 28]
    inception_3a/3x3 -> [32, 128, 28, 28]
    inception_3a/5x5 -> [32, 32, 28, 28]
    inception_3a/pool_proj -> [32, 32, 28, 28]

    因此最终输出将具有以下维度:
    inception_3a/输出 -> [32 (64+128+32+32) 28, 28] -> [32, 256, 28, 28]

    正如 Caffe 日志中所预期的那样:

    Creating Layer inception_3a/output
    inception_3a/output <- inception_3a/1x1
    inception_3a/output <- inception_3a/3x3
    inception_3a/output <- inception_3a/5x5
    inception_3a/output <- inception_3a/pool_proj
    inception_3a/output -> inception_3a/output
    Setting up inception_3a/output
    Top shape: 32 256 28 28 (6422528)
    

    【讨论】:

    • 如果轴是 2 或 3,那么它会在以下维度上?
    • 是的,但请注意,在这种情况下它不会起作用,因为所有层都有不同数量的通道。在实践中,除了 concat 轴之外,所有输入轴都必须具有相同的尺寸,如代码中所述:concat_layer.cpp
    猜你喜欢
    • 2019-11-21
    • 2017-05-08
    • 2017-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-25
    • 1970-01-01
    • 2020-09-29
    相关资源
    最近更新 更多