使用caffe的车辆图像分类

时间:2017-02-04 00:31:09

标签: caffe

嗨,大家好我是深度学习和caffe的新手,但我正在尝试使用Caffe构建汽车,货车,公共汽车和卡车的车辆分类架构。         我使用了已经训练过的模型,但损失值是恒定的以及准确性。因此,我决定从头开始,从2个卷积层2池化层和2个完全连接的层开始,但我仍然有同样的问题,即恒定损耗和常数准确性。         我已经微调了改变大多数值的模型,但无济于事。我在文本文件中设置的数据也被洗牌,因此我对我的错误感到困惑。因此,我在问是否有人可以提供帮助         下面是我的my_train_val.prototxt和解算器文件

**`my_train_val.prototxt`**

name: "CaffeNet"
layer {
  name: "data"
  type: "ImageData"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    mirror: true
    crop_size: 227
    mean_value: 104
    mean_value: 117
    mean_value: 123
    scale: 0.00390625
  }
# mean pixel / channel-wise mean instead of mean image
#  transform_param {
#    crop_size: 127
#    mean_value: 104
#    mean_value: 117
#    mean_value: 123
#    mirror: true
#  }
  image_data_param {
    source: "/home/kay/caffe/models/my_models/train_files.txt"
    batch_size: 10
    new_height: 256
    new_width:  256
  }
}

layer {
  name: "data"
  type: "ImageData"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    mirror: false
    crop_size: 227
    mean_value: 104
    mean_value: 117
    mean_value: 123
    scale: 0.00390625
  }
# mean pixel / channel-wise mean instead of mean image
#  transform_param {
#    crop_size: 127
#    mean_value: 104
#    mean_value: 117
#    mean_value: 123
#    mirror: false
#  }
  image_data_param {
    source: "/home/kay/caffe/models/my_models/train_files.txt"
    batch_size: 10
    new_height: 256
    new_width: 256
  }
}

layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1
   # decay_mult: 1
  }
  param {
    lr_mult: 2
    #decay_mult: 0
  }
  convolution_param {
    num_output: 20
    kernel_size: 3
    stride: 2
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.7
    }
  }
}


layer {
  name: "norm1"
  type: "LRN"
  bottom: "conv1"
  top: "norm1"
 lrn_param {
    local_size: 5
    alpha: 0.0001
    beta: 0.75
  }
}

layer {
  name: "pool1"
  type: "Pooling"
  bottom: "norm1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}

#layer {
#  name: "pool2"
#  type: "Pooling"
#  bottom: "pool1"
# top: "pool2"
#  pooling_param {
#    pool: MAX
#    kernel_size:2
#    stride: 2
#  }
#}


layer {
 name: "conv2"
 type: "Convolution"
 bottom: "pool1"
 top: "conv2"
 param {
    lr_mult: 1
   # decay_mult: 1
  }
  param {
    lr_mult: 2
   # decay_mult: 0
  }
  convolution_param {
    num_output: 40
    kernel_size: 5
   stride: 2
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.7
    }
  }
}

layer {
  name: "pool5"
  type: "Pooling"
  bottom: "conv2"
  top: "pool5"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}

layer {
  name: "fc7"
  type: "InnerProduct"
  bottom: "pool5"
  top: "fc7"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  inner_product_param {
    num_output: 50
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.7
    }
  }
}



layer {
  name: "fc9"
  type: "InnerProduct"
  bottom: "fc7"
  top: "fc9"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  inner_product_param {
    num_output: 2
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.7
    }
  }
}

layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "fc9"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "fc9"
  bottom: "label"
  top: "loss"
} 



net: "/home/kay/caffe/models/my_models/train.prototxt"
test_iter: 1000
test_interval: 500
base_lr: 0.0001
lr_policy: "inv"
gamma: 0.01
power: 0.75
display: 100
max_iter: 2000
momentum: 0.9
weight_decay: 0.0005
snapshot: 100
snapshot_prefix: "models/bvlc_reference_caffenet/caffenet_train"
solver_mode: CPU

**Output**

I0204 01:02:46.402113 11660 blocking_queue.cpp:49] Waiting for data
I0204 01:09:49.701264 11660 solver.cpp:398]     Test net output #0: accuracy = 0.5
I0204 01:09:49.701395 11660 solver.cpp:398]     Test net output #1: loss = 0.694733 (* 1 = 0.694733 loss)
I0204 01:09:50.594509 11660 solver.cpp:219] Iteration 0 (0 iter/s, 424.196s/100 iters), loss = 0.705802
I0204 01:09:50.594566 11660 solver.cpp:238]     Train net output #0: loss = 0.705802 (* 1 = 0.705802 loss)
I0204 01:09:50.594581 11660 sgd_solver.cpp:105] Iteration 0, lr = 0.0001
I0204 01:11:15.426913 11660 solver.cpp:448] Snapshotting to binary proto file models/bvlc_reference_caffenet/caffenet_train_iter_100.caffemodel
I0204 01:11:15.434830 11660 sgd_solver.cpp:273] Snapshotting solver state to binary proto file models/bvlc_reference_caffenet/caffenet_train_iter_100.solverstate
I0204 01:11:16.299131 11660 solver.cpp:219] Iteration 100 (1.16681 iter/s, 85.704s/100 iters), loss = 0.693157
I0204 01:11:16.299195 11660 solver.cpp:238]     Train net output #0: loss = 0.693157 (* 1 = 0.693157 loss)
I0204 01:11:16.299207 11660 sgd_solver.cpp:105] Iteration 100, lr = 9.31012e-05
I0204 01:12:40.570622 11660 solver.cpp:448] Snapshotting to binary proto file models/bvlc_reference_caffenet/caffenet_train_iter_200.caffemodel
I0204 01:12:40.577692 11660 sgd_solver.cpp:273] Snapshotting solver state to binary proto file models/bvlc_reference_caffenet/caffenet_train_iter_200.solverstate
I0204 01:12:41.434355 11660 solver.cpp:219] Iteration 200 (1.17461 iter/s, 85.135s/100 iters), loss = 0.693197
I0204 01:12:41.434409 11660 solver.cpp:238]     Train net output #0: loss = 0.693197 (* 1 = 0.693197 loss)
I0204 01:12:41.434420 11660 sgd_solver.cpp:105] Iteration 200, lr = 8.72196e-05
I0204 01:14:05.489266 11660 solver.cpp:448] Snapshotting to binary proto file models/bvlc_reference_caffenet/caffenet_train_iter_300.caffemodel
I0204 01:14:05.510332 11660 sgd_solver.cpp:273] Snapshotting solver state to binary proto file models/bvlc_reference_caffenet/caffenet_train_iter_300.solverstate
I0204 01:14:06.364553 11660 solver.cpp:219] Iteration 300 (1.17744 iter/s, 84.93s/100 iters), loss = 0.693178
I0204 01:14:06.364609 11660 solver.cpp:238]     Train net output #0: loss = 0.693178 (* 1 = 0.693178 loss)
I0204 01:14:06.364626 11660 sgd_solver.cpp:105] Iteration 300, lr = 8.21377e-05
I0204 01:15:31.256232 11660 solver.cpp:448] Snapshotting to binary proto file models/bvlc_reference_caffenet/caffenet_train_iter_400.caffemodel
I0204 01:15:31.262976 11660 sgd_solver.cpp:273] Snapshotting solver state to binary proto file models/bvlc_reference_caffenet/caffenet_train_iter_400.solverstate
I0204 01:15:32.126720 11660 solver.cpp:219] Iteration 400 (1.16602 iter/s, 85.762s/100 iters), loss = 0.69315
I0204 01:15:32.126785 11660 solver.cpp:238]     Train net output #0: loss = 0.69315 (* 1 = 0.69315 loss)
I0204 01:15:32.126797 11660 sgd_solver.cpp:105] Iteration 400, lr = 7.76969e-05
I0204 01:16:57.399161 11660 solver.cpp:448] Snapshotting to binary proto file models/bvlc_reference_caffenet/caffenet_train_iter_500.caffemodel
I0204 01:16:57.406093 11660 sgd_solver.cpp:273] Snapshotting solver state to binary proto file models/bvlc_reference_caffenet/caffenet_train_iter_500.solverstate

0 个答案:

没有答案