Caffe准确度和损失保持不变

时间:2016-11-20 13:02:32

标签: caffe pycaffe

我正在尝试在窗口上的pycaffe中训练一个卷积神经网络,用于像素分类。

在每次迭代期间,损失和准确度保持不变。 当我使用快照中的权重时,输出只是黑色。

我的问题是:我该如何改变? 到目前为止,我已经学习了学习率(0.01到0.0000001),批量大小(1-20)和权重初始化(高斯与xavier)。

我应该增加图像数量吗?

训练数据集由HDF5文件中的100个图像对(通过减去中位数预处理)组成,如下所示:

[u'data'], [u'label']

尺寸为:

100 x 1 x 584 x 584数据(火车)

标签(火车)

100 x 1 x 139 x 139

10 x 1 x 584 x 584用于数据(测试)

10 x 1 x 139 x 139用于标签(测试)

solver.prototxt如下所示:

net: "train.prototxt" 
test_initialization: true
test_iter: 10
test_interval: 100 
base_lr: 0.0000001
momentum: 0.9
weight_decay: 0.0005
lr_policy: "step"
stepsize: 1000
gamma: 0.1
display: 100
iter_size: 5
max_iter: 50000 
snapshot: 5000 
snapshot_prefix: "models/train"
solver_mode: GPU
type: "SGD"

它调用的网络发布在下面:

# data: 20 1 584 584 (6821120)
# label: 20 1 139 139 (386420)
# conv1: 20 32 582 582 (216783360)
# relu1: 20 32 582 582 (216783360)
# norm1: 20 32 582 582 (216783360)
# pool1: 20 32 290 290 (53824000)
# conv2: 20 32 288 288 (53084160)
# relu2: 20 32 288 288 (53084160)
# norm2: 20 32 288 288 (53084160)
# pool2: 20 32 144 144 (13271040)
# fc6-conv: 20 64 139 139 (24730880)
# relu6: 20 64 139 139 (24730880)
# drop6: 20 64 139 139 (24730880)
# fc7-conv: 20 64 139 139 (24730880)
# relu7: 20 64 139 139 (24730880)
# drop7: 20 64 139 139 (24730880)
# fc8-conv: 20 1 139 139 (386420)
# prob: 20 1 139 139 (386420)
# loss: (1)
# 
layer {
  name: "data"
  type: "HDF5Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  hdf5_data_param {
    source: "../train/train.txt"
    batch_size: 20
  }
}
layer {
  name: "data"
  type: "HDF5Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  hdf5_data_param {
    source: "../train/test.txt"
    batch_size: 1
  }
}
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1.0
    decay_mult: 1.0
  }
  param {
    lr_mult: 2.0
    decay_mult: 0.0
  }
  convolution_param {
    num_output: 32
    kernel_size: 3
    stride: 1
    weight_filler {
      type: "xavier"
      #std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.2
    }
  }
}
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: 4
    stride: 2
  }
}
layer {
  name: "conv2"
  type: "Convolution"
  bottom: "pool1"
  top: "conv2"
  param {
    lr_mult: 1.0
    decay_mult: 1.0
  }
  param {
    lr_mult: 2.0
    decay_mult: 0.0
  }
  convolution_param {
    num_output: 32
    kernel_size: 3
    weight_filler {
      type: "xavier"
      #std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.2
    }
  }
}
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: 2
    stride: 2
  }
}
layer {
  name: "fc6-conv"
  type: "Convolution"
  bottom: "pool2"
  top: "fc6-conv"
  param {
    lr_mult: 1.0
    decay_mult: 1.0
  }
  param {
    lr_mult: 2.0
    decay_mult: 0.0
  }
  convolution_param{
    kernel_size: 6
    num_output: 64
    weight_filler {
      type: "xavier"
      #std: 0.005
    }
    bias_filler {
      type: "constant"
      value: 0.2
    }
  }
}
layer {
  name: "relu6"
  type: "ReLU"
  bottom: "fc6-conv"
  top: "fc6-conv"
}
layer {
  name: "drop6"
  type: "Dropout"
  bottom: "fc6-conv"
  top: "fc6-conv"
  dropout_param {
    dropout_ratio: 0.5
  }
}
layer {
  name: "fc7-conv"
  type: "Convolution"
  bottom: "fc6-conv"
  top: "fc7-conv"
  param {
    lr_mult: 1.0
    decay_mult: 1.0
  }
  param {
    lr_mult: 2.0
    decay_mult: 0.0
  }
  convolution_param {
    kernel_size: 1
    num_output: 64
    weight_filler {
      type: "xavier"
      #std: 0.005
    }
    bias_filler {
      type: "constant"
      value: 0.2
    }
  }
}
layer {
  name: "relu7"
  type: "ReLU"
  bottom: "fc7-conv"
  top: "fc7-conv"
}
layer {
  name: "drop7"
  type: "Dropout"
  bottom: "fc7-conv"
  top: "fc7-conv"
  dropout_param {
    dropout_ratio: 0.5
  }
}
layer {
  name: "fc8-conv"
  type: "Convolution"
  bottom: "fc7-conv"
  top: "fc8-conv"
  param {
    lr_mult: 1.0
    decay_mult: 1.0
  }
  param {
    lr_mult: 2.0
    decay_mult: 0.0
  }
  convolution_param{
    kernel_size: 1
    num_output: 1
    weight_filler {
      type: "xavier"
      #std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.2
    }
  }
}
layer {
  name: "prob"
  type: "Softmax"
  bottom: "fc8-conv"
  top: "prob"
}
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "prob"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}
layer {
  name: "loss"
  type: "SigmoidCrossEntropyLoss"
  bottom: "prob"
  bottom: "label"
  top: "loss"
  loss_weight: 1
  include {
    phase: TRAIN
  }
}

非常感谢帮助!

编辑: 似乎向后传球没有做任何事情。 在上面发布的网络文件中,net.backward只给出{}。 将输入图层重写为:

input: "data"
input_dim: 1
input_dim: 1
input_dim: 584  
input_dim: 584
input: "label"
input_dim: 1
input_dim: 1
input_dim: 139
input_dim: 139

并设置force_backward:true

给出一个零数组。

0 个答案:

没有答案