Browse Source

Fix Transfer Learning crash and compilation

pull/15730/head
Emir Haleva 4 years ago
parent
commit
4c88fcb65c
4 changed files with 6 additions and 12 deletions
  1. +3
    -3
      mindspore/lite/examples/transfer_learning/Makefile
  2. +1
    -7
      mindspore/lite/examples/transfer_learning/prepare_and_run.sh
  3. +1
    -1
      mindspore/lite/examples/transfer_learning/scripts/train.sh
  4. +1
    -1
      mindspore/lite/examples/transfer_learning/src/net_runner.cc

+ 3
- 3
mindspore/lite/examples/transfer_learning/Makefile View File

@@ -1,6 +1,6 @@
BASE_DIR=$(realpath ../../../../)
APP:=bin/net_runner
MSLIB:=mindspore-lite
LMSLIB:=-lmindspore-lite-train
LMDLIB:=-lminddata-lite
MSDIR:=$(realpath package-$(TARGET)/lib)
ifneq ("$(wildcard $(MSDIR)/libhiai.so)","")
@@ -23,10 +23,10 @@ ifeq ($(TARGET),arm64)
CXX := ${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
CFLAGS += --target=aarch64-none-linux-android21 --gcc-toolchain=${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fdata-sections -ffunction-sections
LDFLAGS := --target=aarch64-none-linux-android21 --gcc-toolchain=${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Wl,--gc-sections
LDFLAGS += -L$(MSDIR) -l$(MSLIB) $(LMDLIB) $(LHIAILIB) -pthread -llog -latomic -lm -Wl,-rpath,$(MSDIR)
LDFLAGS += -L$(MSDIR) $(LMSLIB) $(LMDLIB) $(LHIAILIB) -pthread -llog -latomic -lm -Wl,-rpath,$(MSDIR)
else
CFLAGS += -g
LDFLAGS := -L$(MSDIR) -l$(MSLIB) $(LMDLIB) $(LHIAILIB) -lpthread -Wl,-rpath,$(MSDIR)
LDFLAGS := -L$(MSDIR) $(LMSLIB) $(LMDLIB) $(LHIAILIB) -lpthread -Wl,-rpath,$(MSDIR)
endif
LD := ${CXX}



+ 1
- 7
mindspore/lite/examples/transfer_learning/prepare_and_run.sh View File

@@ -95,6 +95,7 @@ mv mindspore-* msl/
cp -r dataset ${PACKAGE}

echo "==========Compiling============"
make clean
make TARGET=${TARGET}
# Copy the executable to the package
@@ -112,10 +113,6 @@ if [ "${TARGET}" == "arm64" ]; then
echo "========Training on Device====="
adb shell "cd /data/local/tmp/package-arm64 && /system/bin/sh train.sh"

echo
echo "===Evaluating trained Model====="
adb shell "cd /data/local/tmp/package-arm64 && /system/bin/sh eval.sh"
echo
else
cd ${PACKAGE} || exit 1
echo "==Evaluating Untrained Model==="
@@ -124,8 +121,5 @@ else
echo "======Training Locally========="
./train.sh

echo "===Evaluating trained Model====="
./eval.sh
cd ..
fi


+ 1
- 1
mindspore/lite/examples/transfer_learning/scripts/train.sh View File

@@ -14,4 +14,4 @@
# limitations under the License.
# ============================================================================

LD_LIBRARY_PATH=./lib/ bin/net_runner -b model/transfer_learning_tod_backbone.ms -f model/transfer_learning_tod_head.ms -e 100 -d dataset -s 20
LD_LIBRARY_PATH=./lib/ bin/net_runner -b model/transfer_learning_tod_backbone.ms -f model/transfer_learning_tod_head.ms -e 100 -d dataset

+ 1
- 1
mindspore/lite/examples/transfer_learning/src/net_runner.cc View File

@@ -211,7 +211,7 @@ int NetRunner::Main() {
float acc = CalculateAccuracy(ds_.val_data());
std::cout << "accuracy on validation data = " << acc << std::endl;

if (cycles_ > 0) {
if (cycles_ > 0 && head_model_ != nullptr) {
auto trained_fn = ms_head_file_.substr(0, ms_head_file_.find_last_of('.')) + "_trained.ms";
mindspore::lite::Model::Export(head_model_, trained_fn.c_str());
}


Loading…
Cancel
Save