You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-16Lines changed: 38 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# MAX78000 Model Training and Synthesis
2
2
3
-
_June 16, 2021_
3
+
_June 21, 2021_
4
4
5
5
The Maxim Integrated AI project is comprised of five repositories:
6
6
@@ -152,14 +152,20 @@ On Linux:
152
152
$ curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash # NOTE: Verify contents of the script before running it!!
153
153
```
154
154
155
-
Then, add to either `~/.bash_profile`, `~/.bashrc`, or `~/.profile` (as shown by the terminal output of the previous step):
156
-
155
+
Then, follow the terminal output of the pyenv-installer and add pyenv to your shell by modifying one or more of `~/.bash_profile`, `~/.bashrc`, `~/.zshrc`, `~/.profile`, or `~/.zprofile`. The instructions differ depending on the shell (bash or zsh). To display the instructions again at any later time:
157
156
```shell
158
-
eval"$(pyenv init -)"
159
-
eval"$(pyenv virtualenv-init -)"
160
-
```
157
+
$ pyenv init
161
158
162
-
If you use zsh as the shell (default on macOS), add these same commands to `~/.zprofile` or `~/.zshrc` in addition to adding them to the bash startup scripts.
159
+
# (The below instructions are intended for common
160
+
# shell setups. See the README for more guidance
161
+
# if they don't apply and/or don't work for you.)
162
+
163
+
# Add pyenv executable to PATH and
164
+
# enable shims by adding the following
165
+
# to ~/.profile and ~/.zprofile:
166
+
...
167
+
...
168
+
```
163
169
164
170
Next, close the Terminal, open a new Terminal and install Python 3.8.10.
165
171
@@ -677,7 +683,7 @@ Example:
677
683
678
684
#### CHW (Channels-Height-Width)
679
685
680
-
The input layer can alternatively also use the CHW format (a sequence of channels). The highest frequency in this data format is the width or X-axis (W), and the lowest frequency is the channel. Assuming an RGB input, all red pixels are followed by all green pixels, followed by all blue pixels.
686
+
The input layer (and *only* the input layer) can alternatively also use the CHW format (a sequence of channels). The highest frequency in this data format is the width or X-axis (W), and the lowest frequency is the channel. Assuming an RGB input, all red pixels are followed by all green pixels, followed by all blue pixels.
681
687
682
688
Example:
683
689
@@ -687,9 +693,11 @@ Example:
687
693
688
694
#### Considerations for Choosing an Input Format
689
695
690
-
The accelerator supports both HWC and CHW input formats to avoid unnecessary data manipulation. Internal layers always use the HWC format.
696
+
The accelerator supports both HWC and CHW input formats to avoid unnecessary data manipulation. Choose the format that results in the least amount of data movement for a given input.
691
697
692
-
In general, HWC is faster since each memory read can deliver data to up to four processors in parallel. On the other hand, four processors must share one data memory instance, which reduces the maximum allowable dimensions.
698
+
Internal layers and the output layer always use the HWC format.
699
+
700
+
In general, HWC is faster since each memory read can deliver data to up to four processors in parallel. On the other hand, four processors must share one data memory instance, which reduces the maximum allowable dimensions of the input layer.
693
701
694
702
#### CHW Input Data Format and Consequences for Weight Memory Layout
695
703
@@ -1128,6 +1136,8 @@ The `quantize.py` software has the following important command line arguments:
1128
1136
1129
1137
*Note: The syntax for the optional YAML file is described below. The same file can be used for both `quantize.py` and `ai8xize.py`.*
1130
1138
1139
+
`quantize.py` does not need access to the dataset.
1140
+
1131
1141
#### Example and Evaluation
1132
1142
1133
1143
Copy the working and tested weight files into the `trained/` folder of the `ai8x-synthesis` project.
@@ -1158,14 +1168,26 @@ In all cases, ensure that the quantizer writes out a checkpoint file that the Ne
1158
1168
1159
1169
### Adding New Network Models and New Datasets to the Training Process
1160
1170
1171
+
#### Model
1172
+
1161
1173
The following step is needed to add new network models:
1162
1174
1163
-
*Implement a new network model based on the constraints described earlier, see [Custom nn.Modules](#custom-nnmodules) (and `models/ai85net.py` for an example). The file must include the `models` data structure that describes the model (name, minimum number of inputs, and whether it can handle 1D or 2D inputs). `models` can list multiple models in the same file.
1175
+
Implement a new network model based on the constraints described earlier, see [Custom nn.Modules](#custom-nnmodules) (and `models/ai85net.py` for an example).
1164
1176
1165
-
The following steps are needed for new data formats and datasets:
1177
+
##### `models` Data Structure
1178
+
1179
+
The file must include the `models` data structure that describes the model. `models` can list multiple models in the same file.
1180
+
1181
+
For each model, three fields are required in the data structure:
1182
+
1183
+
* The `name` field assigns a name to the model for discovery by `train.py`, for example “`resnet5`”.
1184
+
* The `min_input` field describes the minimum width for 2D models, it is typically `1`*(when the input `W` dimension is smaller than `min_input`, it is padded to `min_input`)*.
1185
+
* The `dim` field is either `1` (the model handles 1D inputs) or `2` (the model handles 2D inputs).
1166
1186
1167
1187
#### Data Loader
1168
1188
1189
+
The following steps are needed for new data formats and datasets:
1190
+
1169
1191
Develop a data loader in PyTorch, see https://pytorch.org/tutorials/beginner/data_loading_tutorial.html. See `datasets/mnist.py` for an example.
1170
1192
1171
1193
The data loader must include a loader function, for example `mnist_get_datasets(data, load_train=True, load_test=True)`. `data` is a tuple of the specified data directory and the program arguments, and the two *bools* specify whether training and/or test data should be loaded.
@@ -1184,15 +1206,15 @@ In many cases, image data is delivered as fewer than 8 bits per channel (for exa
1184
1206
1185
1207
On the other hand, a different sensor may produce unsigned data values in the full 8-bit range $[0, 255]$. This range must be mapped to $[–128, +127]$ to match hardware and the trained model. The mapping can be performed during inference by subtracting 128 from each input byte, but this requires extra processing time during inference.
1186
1208
1187
-
#### `datasets` Data Structure
1209
+
#####`datasets` Data Structure
1188
1210
1189
1211
Add the new data loader to a new file in the `datasets` directory (for example `datasets/mnist.py`). The file must include the `datasets` data structure that describes the dataset and points to the new loader. `datasets` can list multiple datasets in the same file.
1190
1212
1191
-
The `input`key describes the dimensionality of the data, and the first dimension is passed as `num_channels` to the model, whereas the remaining dimensions are passed as `dimension`. For example, `'input': (1, 28, 28)` will be passed to the model as `num_channels=1` and `dimensions=(28,28)`.
1213
+
*The `input`field describes the dimensionality of the data, and the first dimension is passed as `num_channels` to the model, whereas the remaining dimensions are passed as `dimension`. For example, `'input': (1, 28, 28)` will be passed to the model as `num_channels=1` and `dimensions=(28,28)`.
1192
1214
1193
-
The optional `regression`key in the structure can be set to `True` to automatically select the `--regression` command line argument. `regression` defaults to `False`.
1215
+
*The optional `regression`field in the structure can be set to `True` to automatically select the `--regression` command line argument. `regression` defaults to `False`.
1194
1216
1195
-
The optional `visualize`key can point to a custom visualization function used when creating `--embedding`. The input to the function (format NCHW for 2D data, or NCL for 1D data) is a batch of data (with N ≤ 100). The default handles square RGB or monochrome images. For any other data, a custom function must be supplied.
1217
+
*The optional `visualize`field can point to a custom visualization function used when creating `--embedding`. The input to the function (format NCHW for 2D data, or NCL for 1D data) is a batch of data (with N ≤ 100). The default handles square RGB or monochrome images. For any other data, a custom function must be supplied.
0 commit comments