如何在CNN Caffemodel中将4096维特征向量减少为1024维向量?

时间:2016-01-06 05:55:29

标签: machine-learning deep-learning caffe conv-neural-network pycaffe

我使用16层VGGnet从图像中提取特征。它输出4096维特征向量。但是,我需要一个1024维向量。如何进一步将这个4096矢量减少为1024矢量?我是否需要在fc7

之上添加新图层

2 个答案:

答案 0 :(得分:3)

是的,您需要在fc7之上添加另一个图层。这就是你的最后几层应该是这样的

layers {
  bottom: "fc7"
  top: "fc7"
  name: "relu7"
  type: RELU
}
layers {
  bottom: "fc7"
  top: "fc7"
  name: "drop7"
  type: DROPOUT
  dropout_param {
    dropout_ratio: 0.5
  }
}
layers {
  name: "fc8"
  bottom: "fc7"
  top: "fc8"
  type: INNER_PRODUCT
  inner_product_param {
    num_output: 1024
  }
  blobs_lr: 0
  blobs_lr: 0
}
layers {
  name: "loss"
  type: SOFTMAX_LOSS
  bottom: "fc8"
  bottom: "label"
  top: "loss/loss"
}
layers {
  name: "accuracy/top1"
  type: ACCURACY
  bottom: "fc8"
  bottom: "label"
  top: "accuracy@1"
  include: { phase: TEST }
  accuracy_param {
    top_k: 1
  }
}

答案 1 :(得分:2)

是的。