Caffe regression prediction same results!

3,889 views
Skip to first unread message

Prabhu

unread,
Feb 9, 2015, 10:22:17 AM2/9/15
to caffe...@googlegroups.com
I have trained the regression model, but when i predict it gives same output results.

net
= caffe.Net(MODEL_FILE,PRETRAINED)
net
.set_mode_cpu()

data4D
= np.zeros([max_value,1,96,96])
data4DL
= np.zeros([max_value,1,1,1])

data4D
[0:max_value,:] = X[200:300,:,:,:]
BATCH_SIZE
= 100

net
.set_input_arrays(data4D.astype(np.float32),data4DL.astype(np.float32))
net
.forward()
ip1
= net.blobs['ip1'].data

print 'Data', ip1.reshape(-1,30)
print 'Shape', ip1.shape



Output
=======

Data
 [[ 65.78652191  37.53079605  30.35254669 ...,  75.85479736  48.45568085
   
78.75233459]
 
[ 65.78652191  37.53079605  30.35254669 ...,  75.85479736  48.45568085
   
78.75233459]
 
[ 65.78652191  37.53079605  30.35254669 ...,  75.85479736  48.45568085
   
78.75233459]
 
...,
 
[ 65.78652191  37.53079605  30.35254669 ...,  75.85479736  48.45568085
   
78.75233459]
 
[ 65.78652191  37.53079605  30.35254669 ...,  75.85479736  48.45568085
   
78.75233459]
 
[ 65.78652191  37.53079605  30.35254669 ...,  75.85479736  48.45568085
   
78.75233459]]


What is the problem here? Looks like the network cant predict
Please help as i have been struggling with this for days.

Prabhu

unread,
Feb 10, 2015, 1:11:51 PM2/10/15
to caffe...@googlegroups.com
Anybody here to help??

I tried these changes but nothing works.

1. I used simple linear regression (connected data to 2 Inner product layers) same result
2. I wrote a separate layer file and set MEMORY_DATA and HDF5_DATA same result.
3. I connected 3 convolution and 3 pooling layers to 1 IP layer, same result
4. i checked the data blobs, it seems to load properly.

The output of

net.blobs['ip1'].data is only 0s
net
.blobs['ip2'].data is the same result no matter what the input



Here is my layer file. i trained my model with another layer file and got converged to test loss = 90.0 after 10k iterations.

name: "FKPred"


layers
{
  name
: "data"
  type
: MEMORY_DATA
  top
: "data"
  top
: "label"
  memory_data_param
{
    batch_size
: 64 #batch size, so how many prediction youu want to do at once. Best is "1", but higher number get better performance
    channels
: 1
    height
: 96
    width
: 96 #number of input

 
}
}



layers
{
  name
: "ip1"
  type
: INNER_PRODUCT
  bottom
: "data"
  top
: "ip1"  
  inner_product_param
{
    num_output
: 100
   
 
}
}

layers
{
  name
: "ip2"
  type
: INNER_PRODUCT
  bottom
: "ip1"
  top
: "ip2"  
  inner_product_param
{
    num_output
: 30
   
 
}
}




Mark Laagland

unread,
Mar 23, 2015, 1:49:59 PM3/23/15
to caffe...@googlegroups.com
Did you find a solution yet?

Op dinsdag 10 februari 2015 19:11:51 UTC+1 schreef Prabhu:

Julio Cesar Mendoza Bobadilla

unread,
Mar 29, 2015, 8:25:50 PM3/29/15
to caffe...@googlegroups.com
I have a similar problem, but with caffe from command line. I am using VGG16 for a 2-class image classificaton problem with 14k samples, I tested with different learning rates [10e-5, 10e-4, 10e-3 ] but I got the same output, seems that the output of the network always is 0(or 1).

There is any typical mistake that caffe beginners :) (like me) perform.

xipen...@gmail.com

unread,
Apr 16, 2015, 4:29:20 AM4/16/15
to caffe...@googlegroups.com
Did you find solutions about the problem? I met the same problem? can you tell me how to do?

在 2015年2月11日星期三 UTC+8上午2:11:51,Prabhu写道:

Yury Gorunov

unread,
Aug 14, 2015, 4:00:01 AM8/14/15
to Caffe Users
Yes. I have the same problem. I try to train linear regression. 



четверг, 16 апреля 2015 г., 11:29:20 UTC+3 пользователь xipen...@gmail.com написал:

della...@gmail.com

unread,
Aug 14, 2015, 7:39:24 AM8/14/15
to Caffe Users
I think this problem may due to the weight initialization schema, can try xavier .
    Here is an regression example: https://github.com/qiexing/caffe-regression

Yury Gorunov

unread,
Aug 14, 2015, 11:35:53 AM8/14/15
to Caffe Users
Thanks! 

I trying it now...

пятница, 14 августа 2015 г., 14:39:24 UTC+3 пользователь della...@gmail.com написал:

glasses cat

unread,
Aug 17, 2015, 5:09:08 AM8/17/15
to Caffe Users
Hi guys,

Great work! I'm using your network with my data, but the loss can't reduce. Can you share you log file and training data with me? I want to do some compare.

Thanks,
Cats

在 2015年8月14日星期五 UTC+8下午7:39:24,della...@gmail.com写道:

helxsz

unread,
Oct 16, 2015, 2:55:23 PM10/16/15
to Caffe Users

Hi, I am making the similar regression like you, the training image is the vehicle image [3* 96* 96], the output label is the rotation angle [anglex, angley]. the model is similar to yours with 3 conv and 3 pooling, and 2 fc, when making the prediction, no matter the output is, it just produces the same result.

I wonder have you solved that problem ?

Андрей Винокуров

unread,
Oct 17, 2015, 4:25:24 AM10/17/15
to Caffe Users
I have same situtation. I suppose, that hdf5 file is not correct and network is adapted for mean of all of input multi label.

helxsz

unread,
Oct 17, 2015, 12:02:30 PM10/17/15
to Caffe Users

 maybe as said there are some problems with the hdf5 data. 


Here is the steps of my preprocessing, before saving the image data into the hdf5,  I normalize the image by dividing the 255, also normailise for the [x, y] label data to the range [-1,1]. My base training rate is 0.0001. At the first beginning of training, the test and train loss is very low, below 0.1,  would be so abnormal ? I wonder the reason caused it would be because of my labeled data are ranged between [-1,1]? 

After the iteration of 5000, the result for different image is different however after iteration 10000, no matter what the image is, the result is the same again.


I tried these ways , 

1) reducing learing rate

2) changing net topology (adding RELUs etc)

3) changing parameter initialization ("xavier" on dev seems especially stabilizing)


still the same problem.


On Monday, 9 February 2015 15:22:17 UTC, Prabhu wrote:

zhang wang

unread,
Jan 21, 2016, 3:31:39 AM1/21/16
to Caffe Users
I got the same problem!
And I had tried the same solutions, as well. None of them works!

But, when I tried to train solver and only test,  I got right results!


在 2015年2月9日星期一 UTC+8下午11:22:17,Prabhu写道:

Jimmy

unread,
Feb 10, 2016, 6:33:05 PM2/10/16
to Caffe Users
I have the same problem. And my problem is worse. The loss can not converge during the training, and always predict the same value in the test.
Any suggestion?
I have tried normalize the data and check the HDF5 data. It does not work in my case.

Nam Vo

unread,
Feb 13, 2016, 2:16:12 AM2/13/16
to Caffe Users
Create a small dataset (like 10-100 examples) and see if the network can fit that data. If it doesn't something is wrong with your implementation.

Viktor

unread,
Aug 9, 2016, 11:19:15 PM8/9/16
to Caffe Users
Hey have some of you solve the problem and could share the solution?

Thanks a lot 

Li Sun

unread,
Aug 17, 2016, 5:59:58 PM8/17/16
to Caffe Users
I also meet similar problem. I am using pre-trained vgg16 net following fully connect layers and l2 loss for multiple labels regression. Each image is corresponding to 3 regression targets. I have tried different kind of data normalisation, and batch norm layer, scale layer, but the output of the network all go to zeros. Could any of you share your solutions please?

Cat

unread,
Dec 14, 2017, 5:44:00 AM12/14/17
to Caffe Users
Bumping this up as I've met the same problem. I have a hunch that there is something wrong with my parameters between the pretrained model and the one i am fine-tuning. But I have a dataset of 227x227 images and labels that have been resized to the dimension of the images (because I'm doing a regression task). When I am deploying the model, I am deploying it on an image of the same size. However, no matter what image I use, I get the exact same predictions.

Has anyone managed to get around this?


On Monday, 9 February 2015 15:22:17 UTC, Prabhu wrote:
Reply all
Reply to author
Forward
0 new messages