-
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 #114 from edgeintelligence/brushup
Brushup
- Loading branch information
Showing
20 changed files
with
337 additions
and
52 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,22 @@ | ||
# kakiage 分散機械学習サーバ | ||
|
||
サーバ側は Python ライブラリとして実装されている。 | ||
|
||
# セットアップ | ||
|
||
Python 3.8+ | ||
|
||
``` | ||
pip install -r requirements.txt | ||
python setup.py develop | ||
``` | ||
|
||
サンプル動作方法: `samples/*/README.md`参照 | ||
|
||
# 配布用ビルド | ||
|
||
``` | ||
python setup.py bdist_wheel | ||
``` | ||
|
||
`dist/kakiage-<version>-py3-none-any.whl` が生成される。利用者は、`pip install /path/to/kakiage-<version>-py3-none-any.whl`を実行することで必須依存パッケージ(numpy 等)とともに kakiage をインストールすることが可能。 |
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,39 @@ | ||
# Sample: MNIST data parallel training | ||
|
||
MNIST画像データセットを分類するMLPを、データ並列方式により分散学習 | ||
|
||
CIFAR10, CIFAR100データセットも使用可能。 | ||
|
||
# ビルド | ||
|
||
``` | ||
npm install | ||
npm run build | ||
``` | ||
|
||
# 学習実行 | ||
|
||
環境変数で設定を行う。 | ||
|
||
- MODEL: mlp, conv, resnet18のいずれか。モデルの種類を指定する。 | ||
- N_CLIENTS: 分散計算に参加するクライアント数。1以上の整数を指定する。指定しない場合は1が指定されたとみなす。 | ||
- EPOCH: 学習エポック数。デフォルトは2。 | ||
- BATCH_SIZE: バッチサイズ。全クライアントの合計。デフォルトは32。 | ||
|
||
実行はuvicorn経由で行う。コマンド例(Mac/Linuxの場合): | ||
|
||
``` | ||
MODEL=conv N_CLIENTS=2 npm run train | ||
``` | ||
|
||
Windowsの場合はsetコマンドを使用して以下のようになる: | ||
|
||
``` | ||
set MODEL=conv | ||
set N_CLIENTS=2 | ||
npm run train | ||
``` | ||
|
||
ブラウザで[http://localhost:8081/](http://localhost:8081/)を開く。`N_CLIENTS`を設定した場合、並列で計算するため、`N_CLIENTS`個のブラウザウィンドウで開く必要がある。注意:1つのウィンドウ上で複数のタブを開いた場合、表示されていないタブの計算速度が低下する。 | ||
|
||
学習したモデルはONNXフォーマットで出力される。WebDNN、ONNX Runtime Web等により、推論に利用することができる。 |
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 |
---|---|---|
@@ -1,18 +1,39 @@ | ||
# サンプル: MNIST data parallel training | ||
# Sample: MNIST data parallel training | ||
|
||
MNIST画像データセットを分類するMLPを、データ並列で学習する | ||
Training MLPs to classify MNIST image datasets in data-parallel distributed training | ||
|
||
# ビルド | ||
CIFAR10, CIFAR100 dataset can be also used. | ||
|
||
# Build | ||
|
||
``` | ||
npm install | ||
npm run build | ||
``` | ||
|
||
# 学習実行 | ||
# Run training | ||
|
||
Settings are made via environment variables. | ||
|
||
- MODEL: one of mlp, conv, resnet18. Specify model type. | ||
- N_CLIENTS: The number of clients participating in the distribution calculation, an integer greater than or equal to 1. If not specified, 1 is assumed to be specified. | ||
- EPOCH: Number of learning epochs. Default is 2. | ||
- BATCH_SIZE: Batch size. Total for all clients. Default is 32. | ||
|
||
Execution is via uvicorn. Command sample (for Mac/Linux): | ||
|
||
``` | ||
MODEL=conv N_CLIENTS=2 npm run train | ||
``` | ||
|
||
On Windows, use the set command: | ||
|
||
``` | ||
set MODEL=conv | ||
set N_CLIENTS=2 | ||
npm run train | ||
``` | ||
|
||
ブラウザで[http://localhost:8081/](http://localhost:8081/)を開く。3並列で計算するため、3つのタブで開く必要がある。 | ||
Open [http://localhost:8081/](http://localhost:8081/) with web browser. If you set `N_CLIENTS`, to run `N_CLIENTS` distributed clients, it must be opened in `N_CLIENTS` browser windows. Note: If three tabs are opened on one window, the computation speed of the tabs not displayed will be reduced. | ||
|
||
The learned models are output in ONNX format and can be used for inference with WebDNN, ONNX Runtime Web, etc. |
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 |
---|---|---|
@@ -1,14 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Kakiage Distributed MNIST Training Sample</title> | ||
<script src="static/index.js"></script> | ||
</head> | ||
<body> | ||
<p id="state"></p> | ||
<p id="messages"></p> | ||
</body> | ||
</html> | ||
<link href="static/index.css" rel="stylesheet" /> | ||
</head> | ||
<body> | ||
<h1>Kakiage Distributed Training</h1> | ||
<main> | ||
<p id="state"></p> | ||
<table> | ||
<tbody> | ||
<tr> | ||
<td>Processed batches</td> | ||
<td id="table-batches"></td> | ||
</tr> | ||
<tr> | ||
<td>Last loss</td> | ||
<td id="table-loss"></td> | ||
</tr> | ||
<tr> | ||
<td>Batch size</td> | ||
<td id="table-batchsize"></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</main> | ||
</body> | ||
</html> |
13 changes: 13 additions & 0 deletions
13
distributed/sample/mnist_data_parallel/public/static/index.css
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,13 @@ | ||
body { | ||
margin: 0; | ||
} | ||
|
||
h1 { | ||
background: linear-gradient(180deg, orange, white); | ||
margin: 0; | ||
padding: 1em; | ||
} | ||
|
||
main { | ||
padding: 1em; | ||
} |
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,18 @@ | ||
# サンプル: テンソルの定数倍 | ||
|
||
テンソルを定数倍にして返す、シンプルなサンプル | ||
|
||
# ビルド | ||
|
||
``` | ||
npm install | ||
npm run build | ||
``` | ||
|
||
# 学習実行 | ||
|
||
``` | ||
npm run train | ||
``` | ||
|
||
ブラウザで[http://localhost:8081/](http://localhost:8081/)を開く。 |
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
# サンプル: テンソルの定数倍 | ||
# Sample: Constant times the tensor | ||
|
||
テンソルを定数倍にして返す、シンプルなサンプル | ||
Simple sample that returns a tensor times a constant | ||
|
||
# ビルド | ||
# Build | ||
|
||
``` | ||
npm install | ||
npm run build | ||
``` | ||
|
||
# 学習実行 | ||
# Run | ||
|
||
``` | ||
npm run train | ||
``` | ||
|
||
ブラウザで[http://localhost:8081/](http://localhost:8081/)を開く。 | ||
Open [http://localhost:8081/](http://localhost:8081/) with web browser. |
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.