Object detection Transfer Learning


I’m trying to transfer-learn with yolo3_darknet53_voc
I have a train_plate.rec file with labelled example. Training SSD on SageMaker works fine so there is presumably no problem with the .rec file.
In gluoncv I’m doing the following:

train_data = gluon.data.DataLoader(

ctx = [mx.cpu()]

net = gcv.model_zoo.get_model('yolo3_darknet53_voc', pretrained=True)


Then calling net.collect_params().reset_ctx(ctx) returns "ValueError: Cannot reset context for Parameter 'yolov30_yolooutputv30_conv0_weight' because it has not been initialized." What is wrong?


using ssd_512_vgg16_atrous_voc instead of yolo3_darknet53_voc produces no error


Hey there,

My guess is that when you run net.reset_class(classes) some of the weights specifically yolov30_yolooutputv30_conv0_weight, yolov30_yolooutputv31_conv0_weight etc become uninitialized.

Taking a look at the reset_class function here: https://gluon-cv.mxnet.io/_modules/gluoncv/model_zoo/yolo/yolo3.html shows that that is indeed the case.

This line

self.prediction = nn.Conv2D(
            all_pred, kernel_size=1, padding=0, strides=1, prefix=self.prediction.prefix)

shows the creation of a new convolution layer in the reset_class function, so you’ll need to initialize the weights for that layer before you can copy to the context you want. You can use something like below to initialize the specific parameters created if you really need the reset_class function.

import mxnet as mx

import gluoncv as gcv





try this:

self.net = get_model('ssd_512_vgg16`Preformatted text`_atrous_custom', classes=self.classes, pretrained_base=False, transfer='voc')
for param in self.net.collect_params().values():
    if param._data is None:       


Hi, I have trained the yolo v3 network with pretrained weights and custom data successful, you can check my blog to find out how to do it if you are interesting.