In code examples, reduced training in CI to single epoch

This commit is contained in:
Emir Haleva 2021-07-24 06:42:17 +03:00
parent 7a537f4cfc
commit a2a7ded639
5 changed files with 22 additions and 14 deletions

View File

@ -2,7 +2,7 @@
display_usage()
{
echo -e "\nUsage: prepare_and_run.sh -D dataset_path [-d mindspore_docker] [-r release.tar.gz] [-t arm64|x86] [-q] [-o] [-b virtual_batch] [-m mindir]\n"
echo -e "\nUsage: prepare_and_run.sh -D dataset_path [-d mindspore_docker] [-r release.tar.gz] [-t arm64|x86] [-q] [-o] [-b virtual_batch] [-m mindir] [-e epochs_to_train]\n"
}
checkopts()
@ -14,7 +14,8 @@ checkopts()
QUANTIZE=""
FP16_FLAG=""
VIRTUAL_BATCH=-1
while getopts 'D:b:d:m:oqr:t:' opt
EPOCHS="-e 5"
while getopts 'D:b:d:e:m:oqr:t:' opt
do
case "${opt}" in
b)
@ -26,6 +27,9 @@ checkopts()
d)
DOCKER=$OPTARG
;;
e)
EPOCHS="-e $OPTARG"
;;
m)
MINDIR_FILE=$OPTARG
;;
@ -138,7 +142,7 @@ if [ "${TARGET}" == "arm64" ]; then
adb push ${PACKAGE} /data/local/tmp/
echo "========Training on Device====="
adb shell "cd /data/local/tmp/package-arm64 && /system/bin/sh train.sh ${FP16_FLAG} -b ${VIRTUAL_BATCH}"
adb shell "cd /data/local/tmp/package-arm64 && /system/bin/sh train.sh ${EPOCHS} ${FP16_FLAG} -b ${VIRTUAL_BATCH}"
echo
echo "===Evaluating trained Model====="
@ -147,7 +151,7 @@ if [ "${TARGET}" == "arm64" ]; then
else
cd ${PACKAGE} || exit 1
echo "======Training Locally========="
./train.sh
./train.sh ${EPOCHS}
echo "===Evaluating trained Model====="
./eval.sh

View File

@ -15,4 +15,4 @@
# ============================================================================
# an simple tutorial as follows, more parameters can be setting
LD_LIBRARY_PATH=./lib/ bin/net_runner -f model/lenet_tod.ms -e 5 -d dataset $1 $2 $3
LD_LIBRARY_PATH=./lib/ bin/net_runner -f model/lenet_tod.ms -d dataset "$@"

View File

@ -2,7 +2,7 @@
display_usage()
{
echo -e "\nUsage: prepare_and_run.sh -D dataset_path [-d mindspore_docker] [-r release.tar.gz] [-t arm64|x86] [-o] [-b virtual_batch] [-m mindir]\n"
echo -e "\nUsage: prepare_and_run.sh -D dataset_path [-d mindspore_docker] [-r release.tar.gz] [-t arm64|x86] [-o] [-b virtual_batch] [-m mindir] [-e epochs_to_train]\n"
}
checkopts()
@ -13,7 +13,8 @@ checkopts()
ENABLEFP16=""
VIRTUAL_BATCH=-1
MINDIR_FILE=""
while getopts 'D:d:m:r:t:ob:' opt
EPOCHS="-e 5"
while getopts 'D:d:e:m:r:t:ob:' opt
do
case "${opt}" in
D)
@ -22,6 +23,9 @@ checkopts()
d)
DOCKER=$OPTARG
;;
e)
EPOCHS="-e $OPTARG"
;;
m)
MINDIR_FILE=$OPTARG
;;
@ -135,7 +139,7 @@ if [ "${TARGET}" == "arm64" ]; then
adb push ${PACKAGE} /data/local/tmp/
echo "========Training on Device====="
adb shell "cd /data/local/tmp/package-arm64 && /system/bin/sh train.sh ${ENABLEFP16} -b ${VIRTUAL_BATCH}"
adb shell "cd /data/local/tmp/package-arm64 && /system/bin/sh train.sh ${EPOCHS} ${ENABLEFP16} -b ${VIRTUAL_BATCH}"
echo
echo "===Evaluating trained Model====="
@ -148,7 +152,7 @@ if [ "${TARGET}" == "arm64" ]; then
else
cd ${PACKAGE} || exit 1
echo "======Training Locally========="
./train.sh
./train.sh ${EPOCHS}
echo "===Evaluating trained Model====="
./eval.sh

View File

@ -15,4 +15,4 @@
# ============================================================================
# an simple tutorial as follows, more parameters can be setting
LD_LIBRARY_PATH=./lib/ bin/net_runner -f model/lenet_tod.ms -e 5 -d dataset $1 $2 $3
LD_LIBRARY_PATH=./lib/ bin/net_runner -f model/lenet_tod.ms -d dataset "$@"

View File

@ -375,8 +375,8 @@ function Run_CodeExamples() {
cd ${basepath}/../../examples/unified_api || exit 1
chmod 777 ./prepare_and_run.sh
chmod 777 ./*/*.sh
./prepare_and_run.sh -D ${datasets_path}/mnist -r ${tarball_path} -t ${target} -m ${models_path}/code_example.mindir >> ${run_code_examples_log_file}
accurate=$(tail -20 ${run_code_examples_log_file} | awk 'NF==3 && /Accuracy is/ { sum += $3} END { print (sum > 1.9) }')
./prepare_and_run.sh -D ${datasets_path}/mnist -r ${tarball_path} -t ${target} -m ${models_path}/code_example.mindir -e 1 >> ${run_code_examples_log_file}
accurate=$(tail -20 ${run_code_examples_log_file} | awk 'NF==3 && /Accuracy is/ { sum += $3} END { print (sum > 1.6) }')
if [ $accurate -eq 1 ]; then
echo "Unified API Trained and reached accuracy" >> ${run_code_examples_log_file}
echo 'code_examples: unified_api pass' >> ${run_benchmark_train_result_file}
@ -391,8 +391,8 @@ function Run_CodeExamples() {
cd ${basepath}/../../examples/train_lenet || exit 1
chmod 777 ./prepare_and_run.sh
chmod 777 ./*/*.sh
./prepare_and_run.sh -D ${datasets_path}/mnist -r ${tarball_path} -t ${target} -m ${models_path}/code_example.mindir >> ${run_code_examples_log_file}
accurate=$(tail -10 ${run_code_examples_log_file} | awk 'NF==3 && /Accuracy is/ { sum += $3} END { print (sum > 1.9) }')
./prepare_and_run.sh -D ${datasets_path}/mnist -r ${tarball_path} -t ${target} -m ${models_path}/code_example.mindir -e 1 >> ${run_code_examples_log_file}
accurate=$(tail -10 ${run_code_examples_log_file} | awk 'NF==3 && /Accuracy is/ { sum += $3} END { print (sum > 1.6) }')
if [ $accurate -eq 1 ]; then
echo "Lenet Trained and reached accuracy" >> ${run_code_examples_log_file}
echo 'code_examples: train_lenet pass' >> ${run_benchmark_train_result_file}