Dear all,
how can I access a specific layer inside a custom layer I am designing - by name? For example, my custom layer is something like
from mxnet import gluon
class customLayer(gluon.HybridBlock):
def __init__(self,_nlayers,**kwards):
super(customLayer,self).__init__(**kwards)
self.nlayers = _nlayers
self.kernel=3
with self.name_scope():
self.net = gluon.nn.HybridSequential()
for i in range(self.nlayers):
self.net.add(gluon.nn.Conv2D(32,kernel_size=self.kernel))
def hybrid_forward(self,F,_x):
x = self.net(_x)
return x
I can get my custom network like:
myNet = customLayer(4)
I can see all variable names with
myNet.collect_params().keys()
but what I get is names for individual weights and biases, e.g. [‘customlayer0_conv0_weight’,
‘customlayer0_conv0_bias’, …], while I need the whole (e.g. conv2) layer?
Thank you.