为alexnet部署错误轴2超出范围

时间:2017-01-09 15:05:36

标签: caffe

我正在使用Alexnet并尝试部署我的网络。但是当我这样做时,我收到以下错误:

I0109 15:16:56.645679  4240 net.cpp:100] Creating Layer fc6
I0109 15:16:56.645681  4240 net.cpp:434] fc6 <- pool5
I0109 15:16:56.645684  4240 net.cpp:408] fc6 -> fc6
I0109 15:16:56.712829  4240 net.cpp:150] Setting up fc6
I0109 15:16:56.712869  4240 net.cpp:157] Top shape: 1 4096 (4096)
I0109 15:16:56.712873  4240 net.cpp:165] Memory required for data: 6778220
I0109 15:16:56.712882  4240 layer_factory.hpp:77] Creating layer relu6
I0109 15:16:56.712890  4240 net.cpp:100] Creating Layer relu6
I0109 15:16:56.712893  4240 net.cpp:434] relu6 <- fc6
I0109 15:16:56.712915  4240 net.cpp:395] relu6 -> fc6 (in-place)
F0109 15:16:56.713158  4240 blob.hpp:122] Check failed: axis_index < num_axes() (2 vs. 2) axis 2 out of range for 2-D Blob with shape 1 4096 (4096)
*** Check failure stack trace: ***

我不知道为什么。它一直对我有用,现在发生了这个错误。

修改

layer {
  name: "data"
  type: "Input"
  top: "data"
  input_param { shape: { dim: 1 dim: 3 dim: 227 dim: 227 } }
}
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: 96
    kernel_size: 11
    stride: 4
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.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.0
    decay_mult: 1.0
  }
  param {
    lr_mult: 2.0
    decay_mult: 0.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.0
    decay_mult: 1.0
  }
  param {
    lr_mult: 2.0
    decay_mult: 0.0
  }
  convolution_param {
    num_output: 384
    pad: 1
    kernel_size: 3
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.0
    }
  }
}
layer {
  name: "relu3"
  type: "ReLU"
  bottom: "conv3"
  top: "conv3"
}
layer {
  name: "conv4"
  type: "Convolution"
  bottom: "conv3"
  top: "conv4"
  param {
    lr_mult: 1.0
    decay_mult: 1.0
  }
  param {
    lr_mult: 2.0
    decay_mult: 0.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.0
    decay_mult: 1.0
  }
  param {
    lr_mult: 2.0
    decay_mult: 0.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.0
    decay_mult: 1.0
  }
  param {
    lr_mult: 2.0
    decay_mult: 0.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: "fc6l"
}

layer {
  name: "drop6"
  type: "Dropout"
  bottom: "fc6l"
  top: "fc6d"
  dropout_param {
    dropout_ratio: 0.5
  }
}
layer {
  name: "fc7"
  type: "InnerProduct"
  bottom: "fc6d"
  top: "fc7"
  param {
    lr_mult: 1.0
    decay_mult: 1.0
  }
  param {
    lr_mult: 2.0
    decay_mult: 0.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"
  type: "InnerProduct"
  bottom: "fc7"
  top: "fc8"
  param {
    lr_mult: 1.0
    decay_mult: 1.0
  }
  param {
    lr_mult: 2.0
    decay_mult: 0.0
  }
  inner_product_param {
    num_output: 612
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.0
    }
  }
}
layer {
  name: "softmax"
  type: "Softmax"
  bottom: "fc8"
  top: "softmax"
}

上面是我的.prototxt(应该与Alexnet相同)

Check failed: axis_index < num_axes() (2 vs. 2) axis 2 out of range for 2-D Blob with shape 1 4096 (4096)
*** Check failure stack trace: ***
    @     0x7f8b8e3125cd  google::LogMessage::Fail()
    @     0x7f8b8e314433  google::LogMessage::SendToLog()
    @     0x7f8b8e31215b  google::LogMessage::Flush()
    @     0x7f8b8e314e1e  google::LogMessageFatal::~LogMessageFatal()
    @     0x7f8b8e92c86a  caffe::Blob<>::CanonicalAxisIndex()
    @     0x7f8b8eaa09c2  caffe::CuDNNReLULayer<>::Reshape()
    @     0x7f8b8e97f481  caffe::Net<>::Init()
    @     0x7f8b8e980d01  caffe::Net<>::Net()
    @     0x7f8b8eac7c5a  caffe::Solver<>::InitTrainNet()
    @     0x7f8b8eac8fc7  caffe::Solver<>::Init()
    @     0x7f8b8eac936a  caffe::Solver<>::Solver()
    @     0x7f8b8e960c53  caffe::Creator_SGDSolver<>()
    @           0x40ac89  train()
    @           0x407590  main
    @     0x7f8b8d283830  __libc_start_main
    @           0x407db9  _start
    @              (nil)  (unknown)
Aborted (core dumped)

示例2:

I0228 13:03:22.875816  4395 layer_factory.hpp:77] Creating layer relu6
I0228 13:03:22.875828  4395 net.cpp:100] Creating Layer relu6
I0228 13:03:22.875831  4395 net.cpp:434] relu6 <- fc-main
I0228 13:03:22.875855  4395 net.cpp:395] relu6 -> fc-main (in-place)
F0228 13:03:22.876565  4395 blob.hpp:122] Check failed: axis_index < num_axes() (2 vs. 2) axis 2 out of range for 2-D Blob with shape 4 4096 (16384)
*** Check failure stack trace: ***
    @     0x7fe1271d85cd  google::LogMessage::Fail()
    @     0x7fe1271da433  google::LogMessage::SendToLog()
    @     0x7fe1271d815b  google::LogMessage::Flush()
    @     0x7fe1271dae1e  google::LogMessageFatal::~LogMessageFatal()
    @     0x7fe1277f286a  caffe::Blob<>::CanonicalAxisIndex()
    @     0x7fe1279669c2  caffe::CuDNNReLULayer<>::Reshape()
    @     0x7fe127845481  caffe::Net<>::Init()
    @     0x7fe127846d01  caffe::Net<>::Net()
    @     0x7fe12798dc5a  caffe::Solver<>::InitTrainNet()
    @     0x7fe12798efc7  caffe::Solver<>::Init()
    @     0x7fe12798f36a  caffe::Solver<>::Solver()
    @     0x7fe127826c53  caffe::Creator_SGDSolver<>()
    @           0x40ac89  train()
    @           0x407590  main
    @     0x7fe126149830  __libc_start_main
    @           0x407db9  _start
    @              (nil)  (unknown)
Aborted (core dumped)


layer {
  name: "fc-main"
  type: "InnerProduct"
  bottom: "pool5"
  top: "fc-main"
  param {
    decay_mult: 1
  }
  param {
    decay_mult: 0
  }
  inner_product_param {
    num_output: 4096
    weight_filler {
      type: "xavier"
      std: 0.005
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "relu6"
  type: "ReLU"
  bottom: "fc-main"
  top: "fc-main"
}
layer {
  name: "drop6"
 type: "Dropout"
  bottom: "fc-main"
  top: "fc-main"
  dropout_param {
    dropout_ratio: 0.5
  }
}

0 个答案:

没有答案