Caffe库:如何在.prototxt中定义多个标签

时间:2019-11-08 14:30:11

标签: c++ neural-network deep-learning caffe

为了在caffe中训练网络,我很难定义带有多个标签的输入源,我无法理解如何定义输入源。

我正在修改caffenet,以获取多个标签以及多个损失和准确性优化。

详细信息:

我有一个标签文件,其中包含一些labels_weather.txt,例如:

  1. 0.jpg 0
  2. 1.jpg 3
  3. 2.jpg 1
  4. 3.jpg 0
  5. 4.jpg 2
  6. ...

此外,我还有另一个文件(labels_day_night.txt),其中包含诸如

  1. 0.jpg 0
  2. 1.jpg 1
  3. 2.jpg 0
  4. 3.jpg 0
  5. 4.jpg 1
  6. ...

我的问题是:

  1. 如何创建从两个数据标签中获取输入的LMDB数据库
  2. 如何添加多个数据输入源
  3. 有解决这个问题的更好方法吗?

这是我的.prototxt文件的第一部分(此部分存在错误):

# My problem is: I don't know how to create LMDB library, and how to create input data layers on prototxt file
name: "Caffenet"

layers {
  name: "data"
  type: DATA
  top: "data"
  top: "label-weather"
  data_param {
    source: "/home/diego/Code/dayweatherDeepLearning/Folds/lmdb/Test_fold_is_0/weather_train_lmdb/"
    backend: LMDB
    batch_size: 50
  }
  transform_param {
    crop_size: 227
    mean_file: "/home/diego/Code/dayweatherDeepLearning/Folds/mean/Test_fold_is_0/mean.binaryproto"
    mirror: true
  }
  include: { phase: TRAIN }
}
layers {
  name: "data"
  type: DATA
  top: "data"
  top: "label-weather"
  data_param {
    source:  "/home/diego/Code/dayweatherDeepLearning/Folds/lmdb/Test_fold_is_0/weather_val_lmdb"
    backend: LMDB
    batch_size: 50
  }
  transform_param {
    crop_size: 227
    mean_file: "/home/diego/Code/dayweatherDeepLearning/Folds/mean/Test_fold_is_0/mean.binaryproto"
    mirror: false
  }
  include: { phase: TEST }
}

layers {
  name: "data"
  type: DATA
  top: "data"
  top: "label-day"
  data_param {
    source: "/home/diego/Code/dayweatherDeepLearning/Folds/lmdb/Test_fold_is_0/day_train_lmdb/"
    backend: LMDB
    batch_size: 50
  }
  transform_param {
    crop_size: 227
    mean_file: "/home/diego/Code/dayweatherDeepLearning/Folds/mean/Test_fold_is_0/mean.binaryproto"
    mirror: true
  }
  include: { phase: TRAIN }
}
layers {
  name: "data"
  type: DATA
  top: "data"
  top: "label-day"
  data_param {
    source:  "/home/diego/Code/dayweatherDeepLearning/Folds/lmdb/Test_fold_is_0/day_val_lmdb"
    backend: LMDB
    batch_size: 50
  }
  transform_param {
    crop_size: 227
    mean_file: "/home/diego/Code/dayweatherDeepLearning/Folds/mean/Test_fold_is_0/mean.binaryproto"
    mirror: false
  }
  include: { phase: TEST }
}

接下来,我在train_val_test.prototxt上遇到了多次丢失,这是文件的结尾(准确性和丢失定义):

...
#First layers here
# accuracy and loss layers:
layers {
  name: "accuracy-weather"
  type: ACCURACY
  bottom: "fc8-weather"
  bottom: "label-weather"
  top: "accuracy-weather"
  include: { phase: TEST }
}
layers {
  name: "loss-weather"
  type: SOFTMAX_LOSS
  bottom: "fc8-weather"
  bottom: "label-weather"
  top: "loss-weather"
}

layers {
  name: "accuracy-day"
  type: ACCURACY
  bottom: "fc8-day"
  bottom: "label-day"
  top: "accuracy-day"
  include: { phase: TEST }
}
layers {
  name: "loss-day"
  type: SOFTMAX_LOSS
  bottom: "fc8-day"
  bottom: "label-day"
  top: "loss-day"
}

0 个答案:

没有答案