Caffe新手使用AlexNet求指教

我的database使用的图片都是800*600的,根据AlexNet的配置强行resize成256*256。LMDB中10个图片作为训练组 10个图片作为检测组(validation),每个图片有一个标签label是1或0
 
经过1000次循环后accuracy是0.5 loss是4.60385
请问大家这个结果是否准确 
我的疑问产生于每个图片就只对应了一个label 两个中的一个正确率也是0.5.。。
 
补充:为了找出具体问题,尝试过把训练组和检测组的数据改成一样的,正确率为100%
 
Prototxt file内容如下
name: "AlexNet"
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
mirror: true
crop_size: 227
mean_file: "testWithAlexNet/alexnet_mean.binaryproto"
}
data_param {
source: "testWithAlexNet/test_train_lmdb"
batch_size: 256
backend: LMDB
}
}
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TEST
}
transform_param {
mirror: false
crop_size: 227
mean_file: "testWithAlexNet/alexnet_mean.binaryproto"
}
data_param {
source: "testWithAlexNet/test_val_lmdb"
batch_size: 50
backend: LMDB
}
}
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: 96
kernel_size: 11
stride: 4
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu1"
type: "ReLU"
bottom: "conv1"
top: "conv1"
}
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: 3
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: 256
pad: 2
kernel_size: 5
group: 2
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0.1
}
}
}
layer {
name: "relu2"
type: "ReLU"
bottom: "conv2"
top: "conv2"
}
layer {
name: "norm2"
type: "LRN"
bottom: "conv2"
top: "norm2"
lrn_param {
local_size: 5
alpha: 0.0001
beta: 0.75
}
}
layer {
name: "pool2"
type: "Pooling"
bottom: "norm2"
top: "pool2"
pooling_param {
pool: MAX
kernel_size: 3
stride: 2
}
}
layer {
name: "conv3"
type: "Convolution"
bottom: "pool2"
top: "conv3"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 384
pad: 1
kernel_size: 3
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3"
type: "ReLU"
bottom: "conv3"
top: "conv3"
}
layer {
name: "conv4"
type: "Convolution"
bottom: "conv3"
top: "conv4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 384
pad: 1
kernel_size: 3
group: 2
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0.1
}
}
}
layer {
name: "relu4"
type: "ReLU"
bottom: "conv4"
top: "conv4"
}
layer {
name: "conv5"
type: "Convolution"
bottom: "conv4"
top: "conv5"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 256
pad: 1
kernel_size: 3
group: 2
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0.1
}
}
}
layer {
name: "relu5"
type: "ReLU"
bottom: "conv5"
top: "conv5"
}
layer {
name: "pool5"
type: "Pooling"
bottom: "conv5"
top: "pool5"
pooling_param {
pool: MAX
kernel_size: 3
stride: 2
}
}
layer {
name: "fc6"
type: "InnerProduct"
bottom: "pool5"
top: "fc6"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 4096
weight_filler {
type: "gaussian"
std: 0.005
}
bias_filler {
type: "constant"
value: 0.1
}
}
}
layer {
name: "relu6"
type: "ReLU"
bottom: "fc6"
top: "fc6"
}
layer {
name: "drop6"
type: "Dropout"
bottom: "fc6"
top: "fc6"
dropout_param {
dropout_ratio: 0.5
}
}
layer {
name: "fc7"
type: "InnerProduct"
bottom: "fc6"
top: "fc7"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 4096
weight_filler {
type: "gaussian"
std: 0.005
}
bias_filler {
type: "constant"
value: 0.1
}
}
}
layer {
name: "relu7"
type: "ReLU"
bottom: "fc7"
top: "fc7"
}
layer {
name: "drop7"
type: "Dropout"
bottom: "fc7"
top: "fc7"
dropout_param {
dropout_ratio: 0.5
}
}
layer {
name: "fc8-test"
type: "InnerProduct"
bottom: "fc7"
top: "fc8-test"
param {
lr_mult: 0.2
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
}
}
}
layer {
name: "accuracy"
type: "Accuracy"
bottom: "fc8-test"
bottom: "label"
top: "accuracy"
include {
phase: TEST
}
}
layer {
name: "loss"
type: "SoftmaxWithLoss"
bottom: "fc8-test"
bottom: "label"
top: "loss"
}
已邀请:

tayloryang21

赞同来自:

I0628 22:30:06.517177 2090364928 solver.cpp:404]     Test net output #0: accuracy = 0.5
I0628 22:30:06.517238 2090364928 solver.cpp:404]     Test net output #1: loss = 4.39029 (* 1 = 4.39029 loss)
I0628 22:30:06.976781 2090364928 solver.cpp:228] Iteration 800, loss = 0.000134329
I0628 22:30:06.976840 2090364928 solver.cpp:244]     Train net output #0: loss = 0.000134331 (* 1 = 0.000134331 loss)
I0628 22:30:06.976866 2090364928 sgd_solver.cpp:106] Iteration 800, lr = 0.001
I0628 22:30:19.053313 2090364928 solver.cpp:228] Iteration 820, loss = 4.19255e-05
I0628 22:30:19.053380 2090364928 solver.cpp:244]     Train net output #0: loss = 4.19276e-05 (* 1 = 4.19276e-05 loss)
I0628 22:30:19.053400 2090364928 sgd_solver.cpp:106] Iteration 820, lr = 0.001
I0628 22:30:31.746179 2090364928 solver.cpp:228] Iteration 840, loss = 5.69591e-05
I0628 22:30:31.746245 2090364928 solver.cpp:244]     Train net output #0: loss = 5.69612e-05 (* 1 = 5.69612e-05 loss)
I0628 22:30:31.746291 2090364928 sgd_solver.cpp:106] Iteration 840, lr = 0.001
I0628 22:30:44.060153 2090364928 solver.cpp:228] Iteration 860, loss = 9.61356e-05
I0628 22:30:44.060226 2090364928 solver.cpp:244]     Train net output #0: loss = 9.61378e-05 (* 1 = 9.61378e-05 loss)
I0628 22:30:44.060250 2090364928 sgd_solver.cpp:106] Iteration 860, lr = 0.001
I0628 22:30:56.140256 2090364928 solver.cpp:228] Iteration 880, loss = 6.67437e-05
I0628 22:30:56.140296 2090364928 solver.cpp:244]     Train net output #0: loss = 6.67458e-05 (* 1 = 6.67458e-05 loss)
I0628 22:30:56.140324 2090364928 sgd_solver.cpp:106] Iteration 880, lr = 0.001
I0628 22:31:07.701757 2090364928 solver.cpp:337] Iteration 900, Testing net (#0)
I0628 22:31:27.327306 2090364928 solver.cpp:404]     Test net output #0: accuracy = 0.5
I0628 22:31:27.327399 2090364928 solver.cpp:404]     Test net output #1: loss = 4.55668 (* 1 = 4.55668 loss)
I0628 22:31:27.777266 2090364928 solver.cpp:228] Iteration 900, loss = 4.73981e-05
I0628 22:31:27.777307 2090364928 solver.cpp:244]     Train net output #0: loss = 4.74002e-05 (* 1 = 4.74002e-05 loss)
I0628 22:31:27.777318 2090364928 sgd_solver.cpp:106] Iteration 900, lr = 0.001
I0628 22:31:39.834630 2090364928 solver.cpp:228] Iteration 920, loss = 7.30325e-05
I0628 22:31:39.834671 2090364928 solver.cpp:244]     Train net output #0: loss = 7.30347e-05 (* 1 = 7.30347e-05 loss)
I0628 22:31:39.834681 2090364928 sgd_solver.cpp:106] Iteration 920, lr = 0.001
I0628 22:31:51.771342 2090364928 solver.cpp:228] Iteration 940, loss = 7.78534e-05
I0628 22:31:51.771380 2090364928 solver.cpp:244]     Train net output #0: loss = 7.78555e-05 (* 1 = 7.78555e-05 loss)
I0628 22:31:51.771390 2090364928 sgd_solver.cpp:106] Iteration 940, lr = 0.001
I0628 22:32:03.791280 2090364928 solver.cpp:228] Iteration 960, loss = 4.63314e-05
I0628 22:32:03.791347 2090364928 solver.cpp:244]     Train net output #0: loss = 4.63335e-05 (* 1 = 4.63335e-05 loss)
I0628 22:32:03.791363 2090364928 sgd_solver.cpp:106] Iteration 960, lr = 0.001
I0628 22:32:15.926801 2090364928 solver.cpp:228] Iteration 980, loss = 0.000106397
I0628 22:32:15.926843 2090364928 solver.cpp:244]     Train net output #0: loss = 0.000106399 (* 1 = 0.000106399 loss)
I0628 22:32:15.926856 2090364928 sgd_solver.cpp:106] Iteration 980, lr = 0.001
I0628 22:32:27.492733 2090364928 solver.cpp:454] Snapshotting to binary proto file testWithAlexNet/caffe_alexnet_train_iter_1000.caffemodel
I0628 22:32:30.064954 2090364928 sgd_solver.cpp:273] Snapshotting solver state to binary proto file testWithAlexNet/caffe_alexnet_train_iter_1000.solverstate
I0628 22:32:31.558936 2090364928 solver.cpp:317] Iteration 1000, loss = 4.06857e-05
I0628 22:32:31.558974 2090364928 solver.cpp:337] Iteration 1000, Testing net (#0)
I0628 22:32:50.675659 2090364928 solver.cpp:404]     Test net output #0: accuracy = 0.5
I0628 22:32:50.675719 2090364928 solver.cpp:404]     Test net output #1: loss = 4.60385 (* 1 = 4.60385 loss)
I0628 22:32:50.675726 2090364928 solver.cpp:322] Optimization Done.
I0628 22:32:50.675732 2090364928 caffe.cpp:222] Optimization Done.

一只怪蜀黍cococoding - 双非机器视觉小硕

赞同来自:

楼主训练数据有打乱么?

lishanlu136

赞同来自:

AlexNet是对1000个类别进行分类的,你要把最后的全连接层的输出改为2,另外,meanfile训练图片的均值,这里当然就是你自己的用于训练的图片的均值,所以需要改,利用tool里面的compute_image_mean.cpp就可以求得。

bea_tree - 学习中

赞同来自:

@lishanlu136 说的对
mean可以加快训练速度
你的结果相当于循环了1000次后得到的结果还是随机猜测一样,所以应该过程中应该有问题

tayloryang21

赞同来自:

name: "AlexNet"
layer {
  name: "data"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    mirror: true
    crop_size: 227
    mean_file: "testWithAlexNet/alexnet_mean.binaryproto"
  }
  data_param {
    source: "testWithAlexNet/test_train_lmdb"
    batch_size: 256
    backend: LMDB
  }
}
layer {
  name: "data"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    mirror: false
    crop_size: 227
    mean_file: "testWithAlexNet/alexnet_mean.binaryproto"
  }
  data_param {
    source: "testWithAlexNet/test_val_lmdb"
    batch_size: 50
    backend: LMDB
  }
}
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: 96
    kernel_size: 11
    stride: 4
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "relu1"
  type: "ReLU"
  bottom: "conv1"
  top: "conv1"
}
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: 3
    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: 256
    pad: 2
    kernel_size: 5
    group: 2
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.1
    }
  }
}
layer {
  name: "relu2"
  type: "ReLU"
  bottom: "conv2"
  top: "conv2"
}
layer {
  name: "norm2"
  type: "LRN"
  bottom: "conv2"
  top: "norm2"
  lrn_param {
    local_size: 5
    alpha: 0.0001
    beta: 0.75
  }
}
layer {
  name: "pool2"
  type: "Pooling"
  bottom: "norm2"
  top: "pool2"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "conv3"
  type: "Convolution"
  bottom: "pool2"
  top: "conv3"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 384
    pad: 1
    kernel_size: 3
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "relu3"
  type: "ReLU"
  bottom: "conv3"
  top: "conv3"
}
layer {
  name: "conv4"
  type: "Convolution"
  bottom: "conv3"
  top: "conv4"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 384
    pad: 1
    kernel_size: 3
    group: 2
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.1
    }
  }
}
layer {
  name: "relu4"
  type: "ReLU"
  bottom: "conv4"
  top: "conv4"
}
layer {
  name: "conv5"
  type: "Convolution"
  bottom: "conv4"
  top: "conv5"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 256
    pad: 1
    kernel_size: 3
    group: 2
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.1
    }
  }
}
layer {
  name: "relu5"
  type: "ReLU"
  bottom: "conv5"
  top: "conv5"
}
layer {
  name: "pool5"
  type: "Pooling"
  bottom: "conv5"
  top: "pool5"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "fc6"
  type: "InnerProduct"
  bottom: "pool5"
  top: "fc6"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  inner_product_param {
    num_output: 4096
    weight_filler {
      type: "gaussian"
      std: 0.005
    }
    bias_filler {
      type: "constant"
      value: 0.1
    }
  }
}
layer {
  name: "relu6"
  type: "ReLU"
  bottom: "fc6"
  top: "fc6"
}
layer {
  name: "drop6"
  type: "Dropout"
  bottom: "fc6"
  top: "fc6"
  dropout_param {
    dropout_ratio: 0.5
  }
}
layer {
  name: "fc7"
  type: "InnerProduct"
  bottom: "fc6"
  top: "fc7"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  inner_product_param {
    num_output: 4096
    weight_filler {
      type: "gaussian"
      std: 0.005
    }
    bias_filler {
      type: "constant"
      value: 0.1
    }
  }
}
layer {
  name: "relu7"
  type: "ReLU"
  bottom: "fc7"
  top: "fc7"
}
layer {
  name: "drop7"
  type: "Dropout"
  bottom: "fc7"
  top: "fc7"
  dropout_param {
    dropout_ratio: 0.5
  }
}
layer {
  name: "fc8-test"
  type: "InnerProduct"
  bottom: "fc7"
  top: "fc8-test"
  param {
    lr_mult: 0.2
    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
    }
  }
}
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "fc8-test"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "fc8-test"
  bottom: "label"
  top: "loss"
}

玉清元始天尊 - 虚无自然大罗三清三境三宝天尊

赞同来自:

10张 牛逼 牛逼

grubby - student of NEU

赞同来自:

你这个图片确实太少了,,

要回复问题请先登录注册