Convolution issue in Caffe

1,882 views
Skip to first unread message

Prabhu

unread,
Jan 22, 2015, 12:11:13 PM1/22/15
to caffe...@googlegroups.com
i have 96x96 pixel images in grayscale format stored in HDF5 files. i am trying to do multi output regression using caffe however convolution is not working. What exactly is the problem here? Why is convolutions not working?

I0122 17:18:39.474860  5074 net.cpp:67] Creating Layer fkp
I0122 17:18:39.474889  5074 net.cpp:356] fkp -> data
I0122 17:18:39.474930  5074 net.cpp:356] fkp -> label
I0122 17:18:39.474967  5074 net.cpp:96] Setting up fkp
I0122 17:18:39.474987  5074 hdf5_data_layer.cpp:57] Loading filename from train.txt
I0122 17:18:39.475103  5074 hdf5_data_layer.cpp:69] Number of files: 1
I0122 17:18:39.475131  5074 hdf5_data_layer.cpp:29] Loading HDF5 filefacialkp-train.hd5
I0122 17:18:40.337786  5074 hdf5_data_layer.cpp:49] Successully loaded 4934 rows
I0122 17:18:40.337862  5074 hdf5_data_layer.cpp:81] output data size: 100,9216,1,1
I0122 17:18:40.337906  5074 net.cpp:103] Top shape: 100 9216 1 1 (921600)
I0122 17:18:40.337929  5074 net.cpp:103] Top shape: 100 30 1 1 (3000)
I0122 17:18:40.337971  5074 net.cpp:67] Creating Layer conv1
I0122 17:18:40.338001  5074 net.cpp:394] conv1 <- data
I0122 17:18:40.338069  5074 net.cpp:356] conv1 -> conv1
I0122 17:18:40.338109  5074 net.cpp:96] Setting up conv1
F0122 17:18:40.599761  5074 blob.cpp:13] Check failed: height >= 0 (-3 vs. 0)


My prototxt layer file is like this

 name: "LogReg"
 layers
{
 top
: "data"
 top
: "label"
 name
: "fkp"
 type
: HDF5_DATA
 hdf5_data_param
{
 source
: "train.txt"
 batch_size
: 100
 
}
 include
{
 phase
: TRAIN
 
}
 
}
 layers
{
 bottom
: "data"
 top
: "conv1"
 name
: "conv1"
 type
: CONVOLUTION
 blobs_lr
: 1
 blobs_lr
: 2
 convolution_param
{
 num_output
: 64
 kernel_size
: 5
 stride
: 1
 weight_filler
{
 type
: "xavier"
 
}
 bias_filler
{
 type
: "constant"
 
}
 
}
 
}
 layers
{
 bottom
: "conv1"
 top
: "pool1"
 name
: "pool1"
 type
: POOLING
 pooling_param
{
 pool
: MAX
 kernel_size
: 2
 stride
: 2
 
}
 
}
 layers
{
 bottom
: "pool1"
 top
: "conv2"
 name
: "conv2"
 type
: CONVOLUTION
 blobs_lr
: 1
 blobs_lr
: 2
 convolution_param
{
 num_output
: 256
 kernel_size
: 5
 stride
: 1
 weight_filler
{
 type
: "xavier"
 
}
 bias_filler
{
 type
: "constant"
 
}
 
}
 
}
 layers
{
 bottom
: "conv2"
 top
: "pool2"
 name
: "pool2"
 type
: POOLING
 pooling_param
{
 pool
: MAX
 kernel_size
: 2
 stride
: 2
 
}
 
}
 layers
{
 bottom
: "pool2"
 top
: "ip1"
 name
: "ip1"
 type
: INNER_PRODUCT
 blobs_lr
: 1
 blobs_lr
: 2
 inner_product_param
{
 num_output
: 500
 weight_filler
{
 type
: "xavier"
 
}
 bias_filler
{
 type
: "constant"
 
}
 
}
 
}
 layers
{
 bottom
: "ip1"
 top
: "ip1"
 name
: "relu1"
 type
: RELU
 
}
 layers
{
 bottom
: "ip1"
 top
: "ip2"
 name
: "ip2"
 type
: INNER_PRODUCT
 blobs_lr
: 1
 blobs_lr
: 2
 inner_product_param
{
 num_output
: 30
 weight_filler
{
 type
: "xavier"
 
}
 bias_filler
{
 type
: "constant"
 
}
 
}
 
}
 layers
{
 bottom
: "ip2"
 bottom
: "label"
 top
: "loss"
 name
: "loss"
 type
: EUCLIDEAN_LOSS
 
}





Bartosz Ludwiczuk

unread,
Jan 22, 2015, 12:26:58 PM1/22/15
to caffe...@googlegroups.com
Hi,
there is no bug in Convolution There is a bug in your data file:)

As you said, your input data is 96x96 image. In Logs from caffe we can see:
Top shape: 100 9216 1 1 (921600)

Of course, 96x96= 921600. but you should not flatten your data. Convolution is 2D operation, so you need to deliver such 2D structure.

So, you need change data preparation step:
  • your data should have dimension [1x96x96] in exactly that order
  • I am not familiar with HDF5 in Caffe, so I get problem with inserting to it 2D image. I was taking  only first row of image.... 
  • So, I encourage you to use "convert_imageset" tool, which can transform image to LMDB or LEVELDB database. Remember about "gray" flag
Message has been deleted

Abhishek Sharma

unread,
Jun 29, 2015, 9:22:32 AM6/29/15
to caffe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages