Just create it via:
self.classifier = nn.ModuleDict()




 hongtaesuk:

Does that mean that the model won’t be able to properly record operations and data flows
for that variable?


No, Autograd will still track all operations on parameters etc. However, the parameters (of the child modules) won’t be registered internally, so that model.parameters() won’t return them (they might be thus missing in when you pass the parameters with this call to the optimizer). Also model.to() won’t grab these parameters and they will stay on the initial device.