Skip to content

Commit 4038b08

Browse files
Add CIFAR100 sample to CI (#113)
* Add CIFAR100 sample to CI
1 parent dd83d46 commit 4038b08

File tree

8 files changed

+87
-15
lines changed

8 files changed

+87
-15
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636
- ./samples/mnist/run_mnist_test.sh
3737
- ./samples/cifar10/run_cifar10_train.sh
3838
- ./samples/cifar10/run_cifar10_test.sh
39+
- ./samples/cifar100/run_cifar100_train.sh
40+
- ./samples/cifar100/run_cifar100_test.sh
3941
- stage: benchmarks
4042
script:
4143
- mkdir build

cmake/download.cmake

+15
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ if (NOT EXISTS "${DATASETS_DIR}/MNIST")
1919
file(REMOVE "${DATASETS_DIR}/MNIST.zip")
2020
endif()
2121

22+
# NB: Download CIFAR10 dataset if it doesn't exist
2223
if (NOT EXISTS "${DATASETS_DIR}/CIFAR10")
2324
message(STATUS "Downloading CIFAR10 dataset")
2425
file(DOWNLOAD
@@ -31,3 +32,17 @@ if (NOT EXISTS "${DATASETS_DIR}/CIFAR10")
3132
file(RENAME "${DATASETS_DIR}/CIFAR-10-JPG-master" "${DATASETS_DIR}/CIFAR10")
3233
file(REMOVE "${DATASETS_DIR}/CIFAR10.zip")
3334
endif()
35+
36+
# NB: Download CIFAR100 dataset if it doesn't exist
37+
if (NOT EXISTS "${DATASETS_DIR}/CIFAR100")
38+
message(STATUS "Downloading CIFAR100 dataset")
39+
file(DOWNLOAD
40+
https://github.com/SemicolonStruggles/CIFAR-100-JPG/archive/refs/heads/master.zip
41+
"${DATASETS_DIR}/CIFAR100.zip" SHOW_PROGRESS)
42+
43+
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "CIFAR100.zip"
44+
WORKING_DIRECTORY "${DATASETS_DIR}")
45+
46+
file(RENAME "${DATASETS_DIR}/CIFAR-100-JPG-master" "${DATASETS_DIR}/CIFAR100")
47+
file(REMOVE "${DATASETS_DIR}/CIFAR100.zip")
48+
endif()

samples/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export DATASETS_DIR=<path-to-deepworks-root>/datasets
88

99
* [MNIST sample](./mnist/README.md)
1010
* [CIFAR10 sample](./cifar10/README.md)
11+
* [CIFAR100 sample](./cifar100/README.md)

samples/cifar10/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ Accuracy: 0.343249
3131
You can also run samples using binary target directly:
3232
* Run train:
3333
```bash
34-
./bin/sample_cifar10_train train <path-to-deepworks>/datasets/CIFAR10 <batch_size> <num_epochs> <dump-frequency>
34+
./bin/sample_cifar10_train train <path-to-deepworks>/datasets/CIFAR10 <batch_size> <num_epochs> <dump-frequency> <path-to-dump>
3535
```
3636

3737
* Run test:
3838
```bash
39-
./bin/sample_cifar10_train test <path-to-deepworks>/datasets/CIFAR10 <batch_size>
39+
./bin/sample_cifar10_train test <path-to-deepworks>/datasets/CIFAR10 <batch_size> <path-to-model>
4040
```

samples/cifar100/README.md

+35-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,40 @@
1-
# Training simple network on CIFAR100 dataset
2-
## Download CIFAR100 dataset
1+
## Training convolution network on CIFAR100 dataset
2+
3+
* Follow instruction to setup enviroment: [DeepWorks samples](../README.md)
4+
5+
* Run train:
6+
```bash
7+
./samples/mnist/run_cifar100_train.sh
8+
```
9+
10+
Possible output:
11+
```bash
12+
Epoch: 0
13+
Loss: 4.60511
14+
Loss: 4.55751
15+
Loss: 4.44311
16+
Loss: 4.42878
17+
Accuracy: 0.0556891
18+
Model saved: build/cifar100_model.bin
319
```
4-
cd /tmp
5-
wget -O CIFAR100.zip https://github.com/SemicolonStruggles/CIFAR-100-JPG/archive/refs/heads/master.zip
6-
unzip CIFAR100.zip
7-
mv CIFAR-100-JPG-master CIFAR100
20+
21+
* Run test:
22+
```bash
23+
./samples/mnist/run_cifar100_test.sh
24+
```
25+
26+
Output:
27+
```bash
28+
Accuracy: 0.0556891
829
```
930

10-
## Build & Run
31+
You can also run samples using binary target directly:
32+
* Run train:
33+
```bash
34+
./bin/sample_cifar100_train train <path-to-deepworks>/datasets/CIFAR100 <batch_size> <num_epochs> <dump-frequency> <path-to-dump>
1135
```
12-
cd <deepworks-build>
13-
cmake ../ -DBUILD_SAMPLES=ON -DCMAKE_BUILD_TYPE=Release
14-
make -j8
15-
./bin/sample_cifar100_train /tmp/CIFAR100 <batch_size> <num_epochs> <dump-frequency>
36+
37+
* Run test:
38+
```bash
39+
./bin/sample_cifar100_train test <path-to-deepworks>/datasets/CIFAR100 <batch_size> <path-to-model>
1640
```

samples/cifar100/run_cifar100_test.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
if test -z ${DW_BUILD_PATH}
4+
then
5+
echo "Please specify DW_BUILD_PATH variable that is the path to deepworks binary files."
6+
exit
7+
fi
8+
9+
if test -z ${DATASETS_DIR}
10+
then
11+
echo "Please specify DATASETS_DIR variable that is the path to deepworks datasets."
12+
exit
13+
fi
14+
15+
${DW_BUILD_PATH}/bin/sample_cifar100_train test ${DATASETS_DIR}/CIFAR100/ 128 ${DW_BUILD_PATH}/cifar100_model.bin
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
if test -z ${DW_BUILD_PATH}
4+
then
5+
echo "Please specify DW_BUILD_PATH variable that is the path to deepworks binary files."
6+
exit
7+
fi
8+
9+
if test -z ${DATASETS_DIR}
10+
then
11+
echo "Please specify DATASETS_DIR variable that is the path to deepworks datasets."
12+
exit
13+
fi
14+
15+
${DW_BUILD_PATH}/bin/sample_cifar100_train train ${DATASETS_DIR}/CIFAR100/ 128 1 1000 ${DW_BUILD_PATH}/cifar100_model.bin

samples/mnist/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ Accuracy: 0.96244
3535
You can also run samples using binary target directly:
3636
* Run train:
3737
```bash
38-
./bin/sample_mnist_train train <path-to-deepworks>/datasets/MNIST <batch_size> <num_epochs> <dump-frequency>
38+
./bin/sample_mnist_train train <path-to-deepworks>/datasets/MNIST <batch_size> <num_epochs> <dump-frequency> <path-to-dump>
3939
```
4040

4141
* Run test:
4242
```bash
43-
./bin/sample_mnist_train test <path-to-deepworks>/datasets/MNIST <batch_size>
43+
./bin/sample_mnist_train test <path-to-deepworks>/datasets/MNIST <batch_size> <path-to-model>
4444
```

0 commit comments

Comments
 (0)