caffe regression

124 views
Skip to first unread message

Ahmed Ibrahim

unread,
Apr 8, 2016, 11:42:13 AM4/8/16
to Caffe Users
is there any real good full tutorial for regression in caffe
I am trying to do regression where the input is an image and the output is a vector of 100 values between 0 and 1 (will it make a difference if i scaled them to [-1,1] ? )
at the last fully connected layer ( am using a modified version of GoogLenet) i am getting values near 0.01 all the time (I expect 70 values near zero and 30 values ranging from 0.3 to 1) , the output from softmax layer is not helping 
here is my last few layer of my network. I am fine tuning from a model trained on Imagenet while i am using COCO-text dataset which is 63K images of text in natural scene images.
I created HDF5 files for the input layer. any help would be appreciated

layer {
  name
: "CAM_conv"
  type
: "Convolution"
  bottom
: "inception_4e/output"
  top
: "CAM_conv"
  param
{
    lr_mult
: 1
    decay_mult
: 1
 
}
  param
{
    lr_mult
: 2
    decay_mult
: 0
 
}
  convolution_param
{
    num_output
: 1024
    pad
: 1
    kernel_size
: 3
   
group: 2
    weight_filler
{
      type
: "gaussian"
      std
: 0.01
   
}
    bias_filler
{
      type
: "constant"
      value
: 1
   
}
 
}
}
layer
{
  name
: "CAM_relu"
  type
: "ReLU"
  bottom
: "CAM_conv"
  top
: "CAM_conv"
}
layer
{
  name
: "CAM_pool"
  type
: "Pooling"
  bottom
: "CAM_conv"
  top
: "CAM_pool"
  pooling_param
{
    pool
: AVE
    kernel_size
: 14
    stride
: 14
 
}
}
layer
{
  name
: "CAM1_fc"
  type
: "InnerProduct"
  bottom
: "CAM_pool"
  top
: "CAM1_fc"
  param
{
    lr_mult
: 1
    decay_mult
: 1
 
}
  param
{
    lr_mult
: 2
    decay_mult
: 0
 
}
  inner_product_param
{
    num_output
: 100
    weight_filler
{
      type
: "xavier"
   
}
    bias_filler
{
      type
: "constant"
      value
: 0
   
}
 
}
}


Jan

unread,
Apr 15, 2016, 10:41:40 AM4/15/16
to Caffe Users
Softmaxing really doesn't make much sense for regression. It turns the vector into some kind of discrete PDF, which is probably not what you want in regression. If there is no real reason to use something else, take an Euclidean loss layer for regression. Aside from that, there is really not much to no difference to classification networks.

Jan

15535...@qq.com

unread,
Sep 14, 2016, 5:56:34 AM9/14/16
to Caffe Users


Hi Jan
 
the input of my net are images without labels while the out are also images.

I get "Check failed status == CUDNN_STATUS_SUCCESS(3 vs. 0) CUDNN_STATUS_BAD_PARAM

my cudnn is 5.0;
cuda 8.0
graphic card GTX 960

my GPU compute capability is 5.2

Can you help me???

This is my net ,

name: "upconv_7"
layer {
  name: "data"
  type: "Data"
  top: "input_data"
  include {
phase: TRAIN
  }
  transform_param {
scale: 0.00390625
    mirror: false
    mean_file: "/home/yuyadan/src/sourceCode/lltcggie-caffe/data/waifu2x_trainning_cpp/waifu2x_mean.binaryproto"
  }
  data_param {
    source: "/home/yuyadan/src/sourceCode/lltcggie-caffe/examples/waifu2x_trainning_cpp/waifu2x_train0_lmdb"
    batch_size: 16
backend: LMDB
  }
}
layer {
  name: "data"
  type: "Data"
  top: "input_data"
  include {
phase: TEST
  }
  transform_param {
scale: 0.00390625
    mirror: false
    mean_file: "/home/yuyadan/src/sourceCode/lltcggie-caffe/data/waifu2x_trainning_cpp/waifu2x_mean.binaryproto"
  }
  data_param {
    source: "/home/yuyadan/src/sourceCode/lltcggie-caffe/examples/waifu2x_trainning_cpp/waifu2x_val0_lmdb"
    batch_size: 16
backend: LMDB
  }
}
layer {
  name: "conv1_layer"
  type: "Convolution"
  bottom: "input_data"
  top: "conv1"
  convolution_param {
    num_output: 16
    kernel_size: 3
    stride: 1
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
  }
}
layer {
  name: "conv1_relu_layer"
  type: "ReLU"
  bottom: "conv1"
  top: "conv1"
  relu_param {
    negative_slope: 0.1
  }
}
layer {
  name: "conv2_layer"
  type: "Convolution"
  bottom: "conv1"
  top: "conv2"
  convolution_param {
    num_output: 32
    kernel_size: 3
    stride: 1
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
  }
}
layer {
  name: "conv2_relu_layer"
  type: "ReLU"
  bottom: "conv2"
  top: "conv2"
  relu_param {
    negative_slope: 0.1
  }
}
layer {
  name: "conv3_layer"
  type: "Convolution"
  bottom: "conv2"
  top: "conv3"
  convolution_param {
    num_output: 64
    kernel_size: 3
    stride: 1
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
  }
}
layer {
  name: "conv3_relu_layer"
  type: "ReLU"
  bottom: "conv3"
  top: "conv3"
  relu_param {
    negative_slope: 0.1
  }
}
layer {
  name: "conv4_layer"
  type: "Convolution"
  bottom: "conv3"
  top: "conv4"
  convolution_param {
    num_output: 128
    kernel_size: 3
    stride: 1
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
  }
}
layer {
  name: "conv4_relu_layer"
  type: "ReLU"
  bottom: "conv4"
  top: "conv4"
  relu_param {
    negative_slope: 0.1
  }
}
layer {
  name: "conv5_layer"
  type: "Convolution"
  bottom: "conv4"
  top: "conv5"
  convolution_param {
    num_output: 128
    kernel_size: 3
    stride: 1
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
  }
}
layer {
  name: "conv5_relu_layer"
  type: "ReLU"
  bottom: "conv5"
  top: "conv5"
  relu_param {
    negative_slope: 0.1
  }
}
layer {
  name: "conv6_layer"
  type: "Convolution"
  bottom: "conv5"
  top: "conv6"
  convolution_param {
    num_output: 256
    kernel_size: 3
    stride: 1
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
  }
}
layer {
  name: "conv6_relu_layer"
  type: "ReLU"
  bottom: "conv6"
  top: "conv6"
  relu_param {
    negative_slope: 0.1
  }
}
layer {
  name: "conv7_layer"
  type: "Deconvolution"
  bottom: "conv6"
  top: "conv7"
  convolution_param {
    num_output: 3
    kernel_size: 4
    stride: 2
    pad: 3
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
  }
}
layer {
  name: "target"
  type: "Data"
  top: "target"
  transform_param{
scale: 0.00390625
  }
  data_param {
source: "/home/yuyadan/src/sourceCode/lltcggie-caffe/examples/waifu2x_trainning_cpp/waifu2x_train1_lmdb"
batch_size: 16 
backend: LMDB
  }
  include: { phase: TRAIN }
}
layer {
  name: "target"
  type: "Data"
  top: "target"
  transform_param{
scale: 0.00390625
  }
  data_param {
source: "/home/yuyadan/src/sourceCode/lltcggie-caffe/examples/waifu2x_trainning_cpp/waifu2x_val1_lmdb"
batch_size: 16 
backend: LMDB
  }
  include: { phase: TEST }
}
layer {
  name: "loss"
  type: "EuclideanLoss"
  bottom: "conv7"
  bottom: "target"
  top: "loss"
  include: { phase: TRAIN }
}


Xinge

unread,
Sep 22, 2016, 9:51:22 AM9/22/16
to Caffe Users
Have you solved your problem? My GPU is Titan X, and i got the same error. Thanks.

在 2016年9月14日星期三 UTC+8下午5:56:34,15535...@qq.com写道:
Reply all
Reply to author
Forward
0 new messages