Pascalcontext-fcn32

131 views
Skip to first unread message

C.F.

unread,
Sep 21, 2016, 6:48:36 AM9/21/16
to Caffe Users
Hi everyone,

I try to fine-tune caffe pascalcontext-fcn32 on my own dataset (with two classes, one is target object, the other is the background), and I get all zero in result, I have no idea where I do something wrong. 

The loss ocsillates around 10k to 100k from the beginning to the end, and when I've tried to print the conv layer weights (print net.params['conv1_1'][0].data), I found that weights are all zero, and finally I also got result is filled with zero. It seems that the network is learning nothing.

Following are my procedure:

1. For preparing data, I have about 100 images. I label the object as 1, background as 0, and object boundaries and hard cases are label as 255 to ignore. I've done data augmentation, and finally have about 30k images. I use this to create LMDB file.

2. I follow pascalcontext-fcn32s. I change the num_output 60 to 2 at layer 'score_fr' and 'upscore' in train_val.prototxt, and fine-tune on the model pascalcontext-fcn32s-heavy.caffemodel. Following are the prototxt files I applied: solver.prototxt, solve.py and train_val.prototxt.
When I start the training, I start getting "Train net output #0 loss = 74031.6 (* 1 = 74031.6 loss)". After about 60k iterations, the loss is still high. I print the conv1_1 weight, all of them are zero.

Could someone can point out what I'm doing wrong, why the loss is always high and the conv weight in the beginning are all zero.

Thanks a lot

Evan Shelhamer

unread,
Sep 22, 2016, 4:16:46 PM9/22/16
to C.F., Caffe Users
Please see the FAQ at fcn.berkeleyvision.org:

Why are all the outputs/gradients/parameters zero?: This is almost universally due to not initializing the weights as needed. To reproduce our FCN training, or train your own FCNs, it is crucial to transplant the weights from the corresponding ILSVRC net such as VGG16. The included surgery.transplant() method can help with this.

Evan Shelhamer





--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users+unsubscribe@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/b80ab515-821b-42de-9720-619d73d6f5fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

C.F.

unread,
Sep 29, 2016, 10:23:12 AM9/29/16
to Caffe Users, beuniq...@gmail.com
Thanks for your help, according to the direction you point out, I found my obvious mistake...
I commented on this line "solver.net.copy_from(weights)" and I forgot to uncomment it, so the weights are not copied at all.

But I still found the weights of layers "score_fr" and "upscore" are all zero, I refer to this method, I add weight initialization, like this:

For layer "score_fr":
  convolution_param {
    num_output: 2 #60
    pad: 0
    kernel_size: 1
    weight_filler {
        type: "xavier"
    }
    bias_filler {
        type: "constant"
    }
  }

For layer "upscore":
  convolution_param {
    num_output: 2 #60
    bias_term: false
    kernel_size: 64
    stride: 32
    group: 2
    weight_filler: { type: "bilinear" }
  }

Now the weights have changed and the loss has decreased.

Here I have a question, I know if I change the layer's name, the original weights would not be copied. so if I did not add weight initialization, the weight will not be automatically initialized?

Thanks
Reply all
Reply to author
Forward
0 new messages