caffe icon indicating copy to clipboard operation
caffe copied to clipboard

ResNet-50 Testing

Open richardmarcum opened this issue 10 years ago • 17 comments

I am trying to get ResNet-50 to run on nvidia's 0.16 branch of caffe and I get the following error.

F0711 15:52:32.952157 23976 net.cpp:797] Check failed: target_blobs.size() == source_layer.blobs_size() (5 vs. 3) Incompatible number of blobs for layer bn_conv1

However, my version of the main branch of caffe runs this network just fine and it was cloned in the beginning of June. I have attached the prototxt, ResNet-50-deploy.txt file I am using in case that helps.

richardmarcum avatar Jul 11 '16 22:07 richardmarcum

0.16 is a development branch. Can you try 0.15 which is the current slated release branch?

thatguymike avatar Jul 11 '16 22:07 thatguymike

I still get the same error on both branches

richardmarcum avatar Jul 11 '16 22:07 richardmarcum

Ah, yes. BVLC caffe uses a different setup for batchnorm where they separate out scale, bias and actual batchnorm. We don't because it kills performance. You need to collapse it down into one layer like:

layer {
  name: "conv1_bn"
  type: "BatchNorm"
  bottom: "conv1_output"
  top: "conv1_bn"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 1
  }
  batch_norm_param {
    scale_filler {
      type: "constant"
      value: 1
    }
    bias_filler {
      type: "constant"
      value: 0
    }
    moving_average_fraction: .9
 }
}

thatguymike avatar Jul 11 '16 22:07 thatguymike

I made those changes and now I am getting the following error.

F0711 17:54:51.704648 9299 net.cpp:404] Top blob 'conv1' produced by multiple sources

richardmarcum avatar Jul 11 '16 22:07 richardmarcum

You likely have top: "conv1" in multiple places.

seanbell avatar Jul 11 '16 23:07 seanbell

Here is my new deploy file after making those changes. ResNet-50-deploy.txt

I had a typo which created the blob error. After correcting the typo, I am not getting the blob error, but the same error I had initially after making the changes suggested by thatguymike.

richardmarcum avatar Jul 11 '16 23:07 richardmarcum

I don't think batch-norm supports in-place computation (which your example uses).

seanbell avatar Jul 12 '16 01:07 seanbell

I have same problem when I fine-tune ResNet network with pre-trained caffemodel provided by https://github.com/KaimingHe/deep-residual-networks

Between nvcaffe-0.14 and nvcaffe-0.15, required blob size of BN layer was increased from 3 to 5. Provided pre-trained model was made when blob size of BN layer was 3 but in current caffe blob size of BN layer is 5. Is there any way to upgrade caffemodel or add compatible code?

dccho avatar Aug 25 '16 07:08 dccho

I got the same error , any one got a solution ?

mingtop avatar Sep 12 '16 03:09 mingtop

@richardmarcum Do you solve the problem of this , by change the defination of bn prototxt? Tanks every much!!

mingtop avatar Sep 12 '16 03:09 mingtop

Still not working, even after applying all the advice from this thread. @thatguymike @lukeyeager help please. Please provide us with a working ResNet prototxt compatible with latest Digits.

EvanWeiner avatar Oct 01 '16 12:10 EvanWeiner

If your only problem is that you can't copy the weights from a pretrained model, then just rename those layers (see my SO post from this morning).

@IsaacYangSLA is working on a distribution method for DIGITS-compatible models (https://github.com/NVIDIA/DIGITS/pull/1077) but it's not ready yet.

lukeyeager avatar Oct 03 '16 17:10 lukeyeager

I got the same error, and what @thatguymike suggested did not seem to work. I guess @dccho had a good idea how this error happens, can anyone fix this compatible problem? ResNet 50 is quite a popular model and the BatchNorm layer is widely used...

guopei avatar Oct 12 '16 17:10 guopei

I have the same question, does someone solve this problem?

401qingkong avatar Nov 02 '16 13:11 401qingkong

I got the smae error @dccho 's idea is make sense. Still have no way to fix it? @thatguymike

JudeLee19 avatar Nov 03 '16 06:11 JudeLee19

It looks like that Batchnorm layer and adjacent Scale layer are integrated in single Batchnorm layer in NVIDIA caffe. However original BVLC/caffe doesn't integrate them. That means any networks and pretrained models using batchnorm and scale layers with original Caffe cannot use in NVIDIA caffe and DIGITS.

dccho avatar Nov 14 '16 06:11 dccho

This is addressed in 0.16

drnikolaev avatar May 14 '17 22:05 drnikolaev