-
Given the following example: class Net(nn.Module):
...
def setup(self):
self.backbone = Backbone(...)
self.classifier = nn.Dense(...)
def __call__(self, inputs):
x = self.backbone(inputs)
x = self.classifier(x)
return x
def create_model(rng, private_params, **kwargs):
model = functools.partial(Net, private_params, **kwargs)
init_batch = jnp.ones((1, 224, 224, 3), jnp.float32)
params = Net(**kwargs).init(rng, init_batch)
return model, params
def net_50(rng, **kwargs):
return _create_model(rng, private_params, **kwargs)
model, params = net_50(RNG, train=False) How would it be possible to extract the backbone submodule from |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 19 replies
-
Hi Roland, can you return an instance of Though I think at the moment you still won't have access to Can you say more about your full use-case for accessing |
Beta Was this translation helpful? Give feedback.
Hi Roland, can you return an instance of
Net
instead a function that creates it? We need to document this better but just callingDense(3)
doesn't actually create any variables, it's just a skeleton "module template" (what we call an "unbound module" in the code)?Though I think at the moment you still won't have access to
Net().backbone
becausesetup
is only called when the module is bound... This actually may be good to improve.Can you say more about your full use-case for accessing
net.backbone
in your code?