Using bvlc_googlenet as pretrained model in digits

391 views
Skip to first unread message

mikos

unread,
Oct 1, 2016, 6:02:46 PM10/1/16
to DIGITS Users

digits 4.0 0.14.0-rc.3 /Ubuntu (aws)

training a 5 class GoogLenet model with about 800 training samples in each class. I was trying to use the bvlc_imagent as pre-trained model. These are the steps I took:

1.  downloaded imagenet from http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel and placed it in /home/ubuntu/models

2. 

a. Pasted the "train_val.prototxt" from here https://github.com/BVLC/caffe/blob/master/models/bvlc_reference_caffenet/train_val.prototxt into the custom network tab and

b. '#' commented out the "source" and "backend" lines (since it was complaning about them)

3. In the pre-trained models text box pasted the path to the '.caffemodel'. in my case: "/home/ubuntu/models/bvlc_googlenet.caffemodel"

I get this error:


ERROR: Cannot copy param 0 weights from layer 'loss1/classifier'; shape mismatch. Source param shape is 1 1 1000 1024 (1024000); target param shape is 6 1024 (6144). To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer.


I have pasted various train_val.prototext from github issues etc and no luck unfortunately, 

I am not sure why this is getting so complicated, in older versions of digits, we could just enter the path to the folder and it was working great for transfer learning. 


Could someone help?

Greg Heinrich

unread,
Oct 3, 2016, 4:59:34 AM10/3/16
to DIGITS Users
Hello,
BVLC models are trained on the 1000-class ImageNet dataset so the classifiers (for example loss1/classifier) have 1000 output neurons. In your case, since you are training on a different number of classes, your classifiers also have a different number of output neurons so you cannot re-use the weights from the BVLC pre-trained model. The error message hints "rename the layer". Did you try this? Rename "loss1/classifier" to "loss1/classifier/retrain" (and do the same for the loss2 and loss3 classifiers).

Regards.

pilu george

unread,
Oct 15, 2018, 3:35:20 AM10/15/18
to DIGITS Users
But after doing this method training is working fine. but when i try the results with deploy.prototxt(checking results with opencv deploy.prototxt.txt and result_model.caffemodel) im getting this error - 

Traceback (most recent call last):
  File "test-without-args-video.py", line 86, in <module>
    detections = net.forward()
cv2.error: OpenCV(3.4.3) /io/opencv/modules/dnn/src/layers/fully_connected_layer.cpp:73: error: (-215:Assertion failed) 1 <= blobs.size() && blobs.size() <= 2 in function 'FullyConnectedLayerImpl'

Is there any solution for this?
Reply all
Reply to author
Forward
0 new messages