如何处理caffe的输出是图像的情况?

时间:2016-08-03 15:40:13

标签: neural-network deep-learning caffe imagenet

我正在处理使用data来生成图像输出的情况,我知道我可以通过定义两个数据层来实现这一点,其中一个顶部是{{1} }和其他输出是label。我使用EUCLIDEAN_LOSS作为我的损失函数。 datalabel都是从leveldb转换的图像数据。我构建的网络如下所示:

name: "Net"
layer {
  name: "data"
  type: "DenseImageData"
  top: "data"
  top: "label"
  dense_image_data_param {
    source: "/home/path/trainDataSet.txt"   
    batch_size: 1                      
    shuffle: true
  }
}


# ***** conv1 *****

layer {
  name: "conv1_1"
  type: "Convolution"
  bottom: "data"
  top: "conv1_1"
  convolution_param {
    num_output: 64
    pad: 1
    kernel_size: 3
  }
}
layer {
  name: "relu1_1"
  type: "ReLU"
  bottom: "conv1_1"
  top: "conv1_1"
}
layer {
  name: "conv1_2"
  type: "Convolution"
  bottom: "conv1_1"
  top: "conv1_2"
  convolution_param {
    num_output: 64
    pad: 1
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "relu1_2"
  type: "ReLU"
  bottom: "conv1_2"
  top: "conv1_2"
}
layer {
  bottom: "conv1_2"
  top: "pool1"
  top: "pool1_mask"
  name: "pool1"
  type: "Pooling"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}


# ***** conv2 *****

layer {
  name: "conv2_1"
  type: "Convolution"
  bottom: "pool1"
  top: "conv2_1"
  convolution_param {
    num_output: 128
    pad: 1
    kernel_size: 3
  }
}
layer {
  name: "relu2_1"
  type: "ReLU"
  bottom: "conv2_1"
  top: "conv2_1"
}
layer {
  name: "conv2_2"
  type: "Convolution"
  bottom: "conv2_1"
  top: "conv2_2"
  convolution_param {
    num_output: 128
    pad: 1
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "relu2_2"
  type: "ReLU"
  bottom: "conv2_2"
  top: "conv2_2"
}
layer {
  bottom: "conv2_2"
  top: "pool2"
  top: "pool2_mask"
  name: "pool2"
  type: "Pooling"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}


# ***** conv3 *****

layer {
  name: "conv3_1"
  type: "Convolution"
  bottom: "pool2"
  top: "conv3_1"
  convolution_param {
    num_output: 256
    pad: 1
    kernel_size: 3
  }
}
layer {
  name: "relu3_1"
  type: "ReLU"
  bottom: "conv3_1"
  top: "conv3_1"
}
layer {
  name: "conv3_2"
  type: "Convolution"
  bottom: "conv3_1"
  top: "conv3_2"
  convolution_param {
    num_output: 256
    pad: 1
    kernel_size: 3
  }
}
layer {
  name: "relu3_2"
  type: "ReLU"
  bottom: "conv3_2"
  top: "conv3_2"
}
layer {
  name: "conv3_3"
  type: "Convolution"
  bottom: "conv3_2"
  top: "conv3_3"
  convolution_param {
    num_output: 256
    pad: 1
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "relu3_3"
  type: "ReLU"
  bottom: "conv3_3"
  top: "conv3_3"
}
layer {
  bottom: "conv3_3"
  top: "pool3"
  top: "pool3_mask"
  name: "pool3"
  type: "Pooling"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}


# ***** conv4 *****

layer {
  name: "conv4_1"
  type: "Convolution"
  bottom: "pool3"
  top: "conv4_1"
  convolution_param {
    num_output: 512
    kernel_size: 3
    stride: 1
    pad: 1
    # dilation: 1
  }
}
layer {
  name: "relu4_1"
  type: "ReLU"
  bottom: "conv4_1"
  top: "conv4_1"
}
layer {
  name: "conv4_2"
  type: "Convolution"
  bottom: "conv4_1"
  top: "conv4_2"
  convolution_param {
    num_output: 512
    kernel_size: 3
    stride: 1
    pad: 1
    # dilation: 1
  }
}
layer {
  name: "relu4_2"
  type: "ReLU"
  bottom: "conv4_2"
  top: "conv4_2"
}
layer {
  name: "conv4_3"
  type: "Convolution"
  bottom: "conv4_2"
  top: "conv4_3"
  convolution_param {
    num_output: 512
    kernel_size: 3
    stride: 1
    pad: 1
    # dilation: 1
  }
}
layer {
  name: "relu4_3"
  type: "ReLU"
  bottom: "conv4_3"
  top: "conv4_3"
}
layer {
  bottom: "conv4_3"
  top: "pool4"
  top: "pool4_mask"
  name: "pool4"
  type: "Pooling"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}


# ***** conv5 *****

layer {
  name: "conv5_1"
  type: "Convolution"
  bottom: "pool4"
  top: "conv5_1"
  convolution_param {
    num_output: 512
    kernel_size: 3
    stride: 1
    pad: 2
    # dilation: 2
  }
}
layer {
  name: "relu5_1"
  type: "ReLU"
  bottom: "conv5_1"
  top: "conv5_1"
}
layer {
  name: "conv5_2"
  type: "Convolution"
  bottom: "conv5_1"
  top: "conv5_2"
  convolution_param {
    num_output: 512
    kernel_size: 3
    stride: 1
    pad: 2
    # dilation: 2
  }
}
layer {
  name: "relu5_2"
  type: "ReLU"
  bottom: "conv5_2"
  top: "conv5_2"
}
layer {
  name: "conv5_3"
  type: "Convolution"
  bottom: "conv5_2"
  top: "conv5_3"
  convolution_param {
    num_output: 512
    kernel_size: 3
    stride: 1
    pad: 2
    # dilation: 2
  }
}
layer {
  name: "relu5_3"
  type: "ReLU"
  bottom: "conv5_3"
  top: "conv5_3"
}
layer {
  bottom: "conv5_3"
  top: "pool5"
  top: "pool5_mask"
  name: "pool5"
  type: "Pooling"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}

# ***** Upsample 5 Layer *****

layer {
  name: "upsample5"
  type: "Upsample"
  bottom: "pool5"
  top: "pool5_D"
  bottom: "pool5_mask"
  upsample_param {
    scale: 2
    upsample_w: 2
    upsample_h: 2
  }
}
layer {
  bottom: "pool5_D"
  top: "conv5_3_D"
  name: "conv5_3_D"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
    }
    num_output: 512
    pad: 1
    kernel_size: 3
  }
}
layer {
  bottom: "conv5_3_D"
  top: "conv5_3_D"
  name: "conv5_3_D_bn"
  type: "BN"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 1
    decay_mult: 0
  }
  bn_param {
    scale_filler {
      type: "constant"
      value: 1
    }
    shift_filler {
      type: "constant"
      value: 0.001
    }
 }
}
layer {
  bottom: "conv5_3_D"
  top: "conv5_3_D"
  name: "relu5_3_D"
  type: "ReLU"
}

layer {
  bottom: "conv5_3_D"
  top: "conv5_2_D"
  name: "conv5_2_D"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
    }
    num_output: 512
    pad: 1
    kernel_size: 3
  }
}
layer {
  bottom: "conv5_2_D"
  top: "conv5_2_D"
  name: "conv5_2_D_bn"
  type: "BN"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 1
    decay_mult: 0
  }
  bn_param {
    scale_filler {
      type: "constant"
      value: 1
    }
    shift_filler {
      type: "constant"
      value: 0.001
    }
 }
}
layer {
  bottom: "conv5_2_D"
  top: "conv5_2_D"
  name: "relu5_2_D"
  type: "ReLU"
}
layer {
  bottom: "conv5_2_D"
  top: "conv5_1_D"
  name: "conv5_1_D"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
    }
    num_output: 512
    pad: 1
    kernel_size: 3
  }
}
layer {
  bottom: "conv5_1_D"
  top: "conv5_1_D"
  name: "conv5_1_D_bn"
  type: "BN"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 1
    decay_mult: 0
  }
  bn_param {
    scale_filler {
      type: "constant"
      value: 1
    }
    shift_filler {
      type: "constant"
      value: 0.001
    }
 }
}
layer {
  bottom: "conv5_1_D"
  top: "conv5_1_D"
  name: "relu5_1_D"
  type: "ReLU"
}


# ***** Upsample 4 Layer *****

layer {
  name: "upsample4"
  type: "Upsample"
  bottom: "conv5_1_D"
  top: "pool4_D"
  bottom: "pool4_mask"
  upsample_param {
    scale: 2
    upsample_w: 3
    upsample_h: 3
  }
}
layer {
  bottom: "pool4_D"
  top: "conv4_3_D"
  name: "conv4_3_D"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
    }
    num_output: 512
    pad: 1
    kernel_size: 3
  }
}
layer {
  bottom: "conv4_3_D"
  top: "conv4_3_D"
  name: "conv4_3_D_bn"
  type: "BN"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 1
    decay_mult: 0
  }
  bn_param {
    scale_filler {
      type: "constant"
      value: 1
    }
    shift_filler {
      type: "constant"
      value: 0.001
    }
 }
}
layer {
  bottom: "conv4_3_D"
  top: "conv4_3_D"
  name: "relu4_3_D"
  type: "ReLU"
}
layer {
  bottom: "conv4_3_D"
  top: "conv4_2_D"
  name: "conv4_2_D"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
    }
    num_output: 512
    pad: 1
    kernel_size: 3
  }
}
layer {
  bottom: "conv4_2_D"
  top: "conv4_2_D"
  name: "conv4_2_D_bn"
  type: "BN"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 1
    decay_mult: 0
  }
  bn_param {
    scale_filler {
      type: "constant"
      value: 1
    }
    shift_filler {
      type: "constant"
      value: 0.001
    }
 }
}
layer {
  bottom: "conv4_2_D"
  top: "conv4_2_D"
  name: "relu4_2_D"
  type: "ReLU"
}
layer {
  bottom: "conv4_2_D"
  top: "conv4_1_D"
  name: "conv4_1_D"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
    }
    num_output: 256
    pad: 1
    kernel_size: 3
  }
}
layer {
  bottom: "conv4_1_D"
  top: "conv4_1_D"
  name: "conv4_1_D_bn"
  type: "BN"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 1
    decay_mult: 0
  }
  bn_param {
    scale_filler {
      type: "constant"
      value: 1
    }
    shift_filler {
      type: "constant"
      value: 0.001
    }
 }
}
layer {
  bottom: "conv4_1_D"
  top: "conv4_1_D"
  name: "relu4_1_D"
  type: "ReLU"
}


# ***** Upsample 3 Layer *****

layer {
  name: "upsample3"
  type: "Upsample"
  bottom: "conv4_1_D"
  top: "pool3_D"
  bottom: "pool3_mask"
  upsample_param {
    upsample_w: 11
    upsample_h: 11
    scale: 2
  }
}
layer {
  bottom: "pool3_D"
  top: "conv3_3_D"
  name: "conv3_3_D"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
    }
    num_output: 256
    pad: 1
    kernel_size: 3
  }
}
layer {
  bottom: "conv3_3_D"
  top: "conv3_3_D"
  name: "conv3_3_D_bn"
  type: "BN"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 1
    decay_mult: 0
  }
  bn_param {
    scale_filler {
      type: "constant"
      value: 1
    }
    shift_filler {
      type: "constant"
      value: 0.001
    }
 }
}
layer {
  bottom: "conv3_3_D"
  top: "conv3_3_D"
  name: "relu3_3_D"
  type: "ReLU"
}
layer {
  bottom: "conv3_3_D"
  top: "conv3_2_D"
  name: "conv3_2_D"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
    }
    num_output: 256
    pad: 1
    kernel_size: 3
  }
}
layer {
  bottom: "conv3_2_D"
  top: "conv3_2_D"
  name: "conv3_2_D_bn"
  type: "BN"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 1
    decay_mult: 0
  }
  bn_param {
    scale_filler {
      type: "constant"
      value: 1
    }
    shift_filler {
      type: "constant"
      value: 0.001
    }
 }
}
layer {
  bottom: "conv3_2_D"
  top: "conv3_2_D"
  name: "relu3_2_D"
  type: "ReLU"
}
layer {
  bottom: "conv3_2_D"
  top: "conv3_1_D"
  name: "conv3_1_D"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
    }
    num_output: 128
    pad: 1
    kernel_size: 3
  }
}
layer {
  bottom: "conv3_1_D"
  top: "conv3_1_D"
  name: "conv3_1_D_bn"
  type: "BN"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 1
    decay_mult: 0
  }
  bn_param {
    scale_filler {
      type: "constant"
      value: 1
    }
    shift_filler {
      type: "constant"
      value: 0.001
    }
 }
}
layer {
  bottom: "conv3_1_D"
  top: "conv3_1_D"
  name: "relu3_1_D"
  type: "ReLU"
}


# ***** Upsample 2 Layer *****

layer {
  name: "upsample2"
  type: "Upsample"
  bottom: "conv3_1_D"
  top: "pool2_D"
  bottom: "pool2_mask"
  upsample_param {
    upsample_w: 22
    upsample_h: 22
    scale: 2
  }
}
layer {
  bottom: "pool2_D"
  top: "conv2_2_D"
  name: "conv2_2_D"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
    }
    num_output: 128
    pad: 1
    kernel_size: 3
  }
}
layer {
  bottom: "conv2_2_D"
  top: "conv2_2_D"
  name: "conv2_2_D_bn"
  type: "BN"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 1
    decay_mult: 0
  }
  bn_param {
    scale_filler {
      type: "constant"
      value: 1
    }
    shift_filler {
      type: "constant"
      value: 0.001
    }
 }
}
layer {
  bottom: "conv2_2_D"
  top: "conv2_2_D"
  name: "relu2_2_D"
  type: "ReLU"
}
layer {
  bottom: "conv2_2_D"
  top: "conv2_1_D"
  name: "conv2_1_D"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
    }
    num_output: 64
    pad: 1
    kernel_size: 3
  }
}
layer {
  bottom: "conv2_1_D"
  top: "conv2_1_D"
  name: "conv2_1_D_bn"
  type: "BN"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 1
    decay_mult: 0
  }
  bn_param {
    scale_filler {
      type: "constant"
      value: 1
    }
    shift_filler {
      type: "constant"
      value: 0.001
    }
 }
}
layer {
  bottom: "conv2_1_D"
  top: "conv2_1_D"
  name: "relu2_1_D"
  type: "ReLU"
}


# ***** Upsample 1 Layer *****

layer {
  name: "upsample1"
  type: "Upsample"
  bottom: "conv2_1_D"
  top: "pool1_D"
  bottom: "pool1_mask"
  upsample_param {
    upsample_w: 44
    upsample_h: 44
    scale: 2
  }
}
layer {
  bottom: "pool1_D"
  top: "conv1_2_D"
  name: "conv1_2_D"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
    }
    num_output: 64
    pad: 1
    kernel_size: 3
  }
}
layer {
  bottom: "conv1_2_D"
  top: "conv1_2_D"
  name: "conv1_2_D_bn"
  type: "BN"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 1
    decay_mult: 0
  }
  bn_param {
    scale_filler {
      type: "constant"
      value: 1
    }
    shift_filler {
      type: "constant"
      value: 0.001
    }
 }
}
layer {
  bottom: "conv1_2_D"
  top: "conv1_2_D"
  name: "relu1_2_D"
  type: "ReLU"
}
layer {
  bottom: "conv1_2_D"
  top: "conv1_1_D"
  name: "conv1_1_D"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }

  convolution_param {
    weight_filler {
      type: "msra"
    }
    bias_filler {
      type: "constant"
    }
    num_output: 30976 
    pad: 1
    kernel_size: 3
  }
}


## ***** Output Layer *****
#
#layer {
#  name: "conv5_176"
#  type: "Convolution"
#  bottom: "conv5_3"
#  top: "conv8_176"
#  convolution_param {
#    num_output: 30976 #176X176
#    kernel_size: 1
#    stride: 1
#    # dilation: 1
#  }
#}


# ***** Softmax loss *****

layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "conv1_1_D"
  bottom: "label"
  top: "loss"
  softmax_param {engine: CAFFE}
  loss_weight: 1.0
}

问题是,当我训练网络时,我对问题的解释如下:

I1127 14:13:15.155333 36915 net.cpp:90] Creating Layer upsample1
I1127 14:13:15.155349 36915 net.cpp:410] upsample1 <- conv2_1_D
I1127 14:13:15.155360 36915 net.cpp:410] upsample1 <- pool1_mask
I1127 14:13:15.155375 36915 net.cpp:368] upsample1 -> pool1_D
I1127 14:13:15.155395 36915 net.cpp:120] Setting up upsample1
F1127 14:13:15.155416 36915 upsample_layer.cpp:63] Check failed: bottom[0]->height() == bottom[1]->height() (22 vs. 44) 

它表明损失层的两个底部是相同的通道。

有人可以就如何解决问题提出一些建议吗?

0 个答案:

没有答案