forked from microsoft/nni
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from microsoft/master
merge master
- Loading branch information
Showing
74 changed files
with
1,988 additions
and
4,230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
name: Question for NNI Student Program China / NNI 学生项目问题表单 | ||
about: NNI Student Program China issue template on Github | ||
|
||
--- | ||
<!-- Here is an issue template for NNI student program China. You are encouraged to raise concerns about any issue and share your ideas of NNI or our student program. Both Chinese and English are acceptable. | ||
If it is a general question / idea of NNI, you could just make a short summary. | ||
If it is a operational issue, please fill operational issue template and provide as many details as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks!--> | ||
|
||
## 问题概述 | ||
|
||
**请简要概述您的问题 / 观点** : | ||
|
||
|
||
## 其他建议 | ||
|
||
**是否需要更新文档(是 / 否)** : | ||
**其他分享内容** : | ||
|
||
## General Question | ||
|
||
**Short summary about the question / idea** : | ||
|
||
|
||
## Other Advice | ||
**Need to update document ( yes / no )** : | ||
**Anything else we need to know** : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# NAS Visualization (Experimental) | ||
|
||
## Built-in Trainers Support | ||
|
||
Currently, only ENAS and DARTS support visualization. Examples of [ENAS](./ENAS.md) and [DARTS](./DARTS.md) has demonstrated how to enable visualization in your code, namely, adding this before `trainer.train()`: | ||
|
||
```python | ||
trainer.enable_visualization() | ||
``` | ||
|
||
This will create a directory `logs/<current_time_stamp>` in your working folder, in which you will find two files `graph.json` and `log`. | ||
|
||
You don't have to wait until your program finishes to launch NAS UI, but it's important that these two files have been already created. Launch NAS UI with | ||
|
||
```bash | ||
nnictl webui nas --logdir logs/<current_time_stamp> --port <port> | ||
``` | ||
|
||
## Visualize a Customized Trainer | ||
|
||
If you are interested in how to customize a trainer, please read this [doc](./Advanced.md#extend-the-ability-of-one-shot-trainers). | ||
|
||
You should do two modifications to an existing trainer to enable visualization: | ||
|
||
1. Export your graph before training, with | ||
|
||
```python | ||
vis_graph = self.mutator.graph(inputs) | ||
# `inputs` is a dummy input to your model. For example, torch.randn((1, 3, 32, 32)).cuda() | ||
# If your model has multiple inputs, it should be a tuple. | ||
with open("/path/to/your/logdir/graph.json", "w") as f: | ||
json.dump(vis_graph, f) | ||
``` | ||
|
||
2. Logging the choices you've made. You can do it once per epoch, once per mini-batch or whatever frequency you'd like. | ||
|
||
```python | ||
def __init__(self): | ||
# ... | ||
self.status_writer = open("/path/to/your/logdir/log", "w") # create a writer | ||
|
||
def train(self): | ||
# ... | ||
print(json.dumps(self.mutator.status()), file=self.status_writer, flush=True) # dump a record of status | ||
``` | ||
|
||
If you are implementing your customized trainer inheriting `Trainer`. We have provided `enable_visualization()` and `_write_graph_status()` for easy-to-use purposes. All you need to do is calling `trainer.enable_visualization()` before start, and `trainer._write_graph_status()` each time you want to do the logging. But remember both of these APIs are experimental and subject to change in future. | ||
|
||
Last but not least, invode NAS UI with | ||
|
||
```bash | ||
nnictl webui nas --logdir /path/to/your/logdir | ||
``` | ||
|
||
## NAS UI Preview | ||
|
||
 | ||
|
||
 | ||
|
||
## Limitations | ||
|
||
* NAS visualization only works with PyTorch >=1.4. We've tested it on PyTorch 1.3.1 and it doesn't work. | ||
* We rely on PyTorch support for tensorboard for graph export, which relies on `torch.jit`. It will not work if your model doesn't support `jit`. | ||
* There are known performance issues when loading a moderate-size graph with many op choices (like DARTS search space). | ||
|
||
## Feedback | ||
|
||
NAS UI is currently experimental. We welcome your feedback. [Here](https://github.com/microsoft/nni/pull/2085) we have listed all the to-do items of NAS UI in the future. Feel free to comment (or [submit a new issue](https://github.com/microsoft/nni/issues/new?template=enhancement.md)) if you have other suggestions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.