"sgl-router/src/git@developer.sourcefind.cn:change/sglang.git" did not exist on "a59cbea92d9f2745f7e159e8f938cd4458435c5f"
Unverified Commit 84b9c9b2 authored by Yuge Zhang's avatar Yuge Zhang Committed by GitHub
Browse files

More improvements of NAS documents (#4741)

parent a31d37e5
...@@ -5,7 +5,7 @@ Python API Reference ...@@ -5,7 +5,7 @@ Python API Reference
:maxdepth: 1 :maxdepth: 1
Hyperparameter Optimization <hpo> Hyperparameter Optimization <hpo>
Neural Architecture Search <nas> Neural Architecture Search <nas/index>
Model Compression <compression> Model Compression <compression>
Experiment <experiment> Experiment <experiment>
Others <others> Others <others>
...@@ -45,7 +45,18 @@ class Cell(nn.Module): ...@@ -45,7 +45,18 @@ class Cell(nn.Module):
A cell consists of multiple "nodes". Each node is a sum of multiple operators. Each operator is chosen from A cell consists of multiple "nodes". Each node is a sum of multiple operators. Each operator is chosen from
``op_candidates``, and takes one input from previous nodes and predecessors. Predecessor means the input of cell. ``op_candidates``, and takes one input from previous nodes and predecessors. Predecessor means the input of cell.
The output of cell is the concatenation of some of the nodes in the cell (currently all the nodes). The output of cell is the concatenation of some of the nodes in the cell (by default all the nodes).
Two examples of searched cells are illustrated in the figure below.
In these two cells, ``op_candidates`` are series of convolutions and pooling operations.
``num_nodes_per_node`` is set to 2. ``num_nodes`` is set to 5. ``merge_op`` is ``loose_end``.
Please take a look at this
`review article <https://sh-tsang.medium.com/review-nasnet-neural-architecture-search-network-image-classification-23139ea0425d>`__
if you are interested in details.
.. image:: ../../../img/nasnet_cell.png
:width: 900
:align: center
Here is a glossary table, which could help better understand the terms used above: Here is a glossary table, which could help better understand the terms used above:
...@@ -56,9 +67,9 @@ class Cell(nn.Module): ...@@ -56,9 +67,9 @@ class Cell(nn.Module):
* - Name * - Name
- Brief Description - Brief Description
* - Cell * - Cell
- A cell consists of several nodes. - A cell consists of ``num_nodes`` nodes.
* - Node * - Node
- A node is the **sum** of several operators. - A node is the **sum** of ``num_ops_per_node`` operators.
* - Operator * - Operator
- Each operator is independently chosen from a list of user-specified candidate operators. - Each operator is independently chosen from a list of user-specified candidate operators.
* - Operator's input * - Operator's input
...@@ -66,7 +77,7 @@ class Cell(nn.Module): ...@@ -66,7 +77,7 @@ class Cell(nn.Module):
* - Predecessors * - Predecessors
- Input of cell. A cell can have multiple predecessors. Predecessors are sent to *preprocessor* for preprocessing. - Input of cell. A cell can have multiple predecessors. Predecessors are sent to *preprocessor* for preprocessing.
* - Cell's output * - Cell's output
- Output of cell. Usually concatenation of several nodes (possibly all nodes) in the cell. Cell's output, - Output of cell. Usually concatenation of some nodes (possibly all nodes) in the cell. Cell's output,
along with predecessors, are sent to *postprocessor* for postprocessing. along with predecessors, are sent to *postprocessor* for postprocessing.
* - Preprocessor * - Preprocessor
- Extra preprocessing to predecessors. Usually used in shape alignment (e.g., predecessors have different shapes). - Extra preprocessing to predecessors. Usually used in shape alignment (e.g., predecessors have different shapes).
...@@ -142,11 +153,11 @@ class Cell(nn.Module): ...@@ -142,11 +153,11 @@ class Cell(nn.Module):
class Preprocessor: class Preprocessor:
def __init__(self): def __init__(self):
self.conv1 = nn.Conv2d(16, 32, 1) self.conv1 = nn.Conv2d(16, 32, 1)
self.conv2 = nn.Conv2d(64, 32, 1) self.conv2 = nn.Conv2d(64, 32, 1)
def forward(self, x): def forward(self, x):
return [self.conv1(x[0]), self.conv2(x[1])] return [self.conv1(x[0]), self.conv2(x[1])]
cell = nn.Cell([nn.Conv2d(32, 32, 3), nn.MaxPool2d(3)], 4, 1, 2, preprocessor=Preprocessor()) cell = nn.Cell([nn.Conv2d(32, 32, 3), nn.MaxPool2d(3)], 4, 1, 2, preprocessor=Preprocessor())
cell([torch.randn(1, 16, 48, 48), torch.randn(1, 64, 48, 48)]) # the two inputs will be sent to conv1 and conv2 respectively cell([torch.randn(1, 16, 48, 48), torch.randn(1, 64, 48, 48)]) # the two inputs will be sent to conv1 and conv2 respectively
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment