Model_zoo grad_req values


#1

Dear all,

I am playing around models in gluoncv.model_zoo. When I load a resnet family model for image classification, e.g.

mynet =  model_zoo.get_model('cifar_resnet110_v2',classes=1,pretrained=False)

the first Batch normalization of the features has grad_req == 'null' in all it’s variables:

In [30]: mynet.features[0]
Out[30]: BatchNorm(momentum=0.9, eps=1e-05, fix_gamma=True, use_global_stats=False, axis=1, in_channels=None)

In [29]: for param in mynet.features[0].collect_params().values():
    ...:     print (param.grad_req)
    ...:     
null
null
null
null

I am under the impression that the first two params must be write for the model layer to be able to train. For example, if I define a simple BatchNorm layer in a network, this is the case

In [32]: mynet = gluon.nn.HybridSequential()

In [33]: with mynet.name_scope():
    ...:     mynet.add(gluon.nn.BatchNorm())
    ...:     

In [34]: for param in mynet.collect_params().values():
    ...:     print (param.grad_req)
    ...:     
write
write
null
null

Am I missing something?


#2

stupid me: BatchNorm(center=False, scale = False)