Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Replace layer choice with selected module after applied fixed architecture #2420

Merged
merged 6 commits into from
May 18, 2020

Conversation

ultmaster
Copy link
Contributor

@ultmaster ultmaster commented May 11, 2020

This should solve the problem #2401 is trying to solve.

"""
if module is None:
module = self.model
for name, mutable in module.named_children():
Copy link
Contributor

@liuzhe-lz liuzhe-lz May 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the util function to traverse here?
Seems because setting module by full name is not trival.

global_name = (prefix + "." if prefix else "") + name
if isinstance(mutable, LayerChoice):
chosen = self._fixed_arc[mutable.key]
if sum(chosen) == 1 and max(chosen) == 1 and not mutable.return_mask:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the meaning of not mutable.return_mask?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If true, layer choice will return the choice vector. If we replace the layer choice module with the selected module, choice vector will be no longer available, and users’ code will crash.

@QuanluZhang
Copy link
Contributor

please update doc at proper place.

@@ -176,7 +176,7 @@ For example,
}
```

After applying, the model is then fixed and ready for final training. The model works as a single model, although it might contain more parameters than expected. This comes with pros and cons. The good side is, you can directly load the checkpoint dumped from supernet during the search phase and start retraining from there. However, this is also a model with redundant parameters and this may cause problems when trying to count the number of parameters in the model. For deeper reasons and possible workarounds, see [Trainers](./NasReference.md).
After applying, the model is then fixed and ready for final training. The model works as a single model, and unused parameters and modules will be pruned.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"will be" -> "are"

@ultmaster ultmaster merged commit f42e53d into microsoft:master May 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to get normal model according to the searched best architecture json file for NAS?
3 participants