使用restoreMultiLayerNetwork()加载DL4J模型时,“classloader-namespace”无法访问的库

我无法找到如何摆脱/解决以下错误,当使用Android API> = 24使用DL4J方法restoreMultiLayerNetwork加载神经网络模型时发生:

调用方法restoreMultiLayerNetwork中的以下行时会发生错误:

params = Nd4j.read(ins2);

InputStream ins2 = getResources().openRawResource(getResources().getIdentifier("coefficients", "raw", getPackageName()));

“coefficients.bin”是导出DL4J神经网络时由DL4J的以下方法创建的系数文件:

ModelSerializer.writeModel(model, locationToSave, saveUpdater);

Errors: Libraries not accessible for "classloader-namespace"

E / linker:库“/vendor/lib64/libcutils.so”(“/ vendor/lib64/libcutils.so”)需要或通过“/data/app/com.arai.arai-1/lib/arm64/进行调整libjnind4jcpu.so“无法访问命名空间:[name =”classloader-namespace“,ld_library_paths =”“,default_library_paths =”/ data / app / com.arai.arai-1 / lib / arm64:/ system / fake- libs64:/data/app/com.arai.arai-1/base.apk / lib目录/ arm64-V8A:/data/app/com.arai.arai-1/split_lib_dependencies_apk.apk / lib目录/ arm64-V8A: /data/app/com.arai.arai-1/split_lib_slice_0_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_1_apk.apk!/lib/arm64-v8a:/data /app/com.arai.arai-1/split_lib_slice_2_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_3_apk.apk!/lib/arm64-v8a:/data/app /com.arai.arai-1/split_lib_slice_4_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_5_apk.apk!/lib/arm64-v8a:/data/app/com !.arai.arai-1 / split_lib_slice_6_apk.apk / lib目录/ arm64-V8A:/data/app/com.arai.arai-1/split_lib_slice_7_apk.apk / lib目录/ arm64-V8A:/data/app/com.ara i.arai-1 / split_lib_slice_8_apk.apk! “/dall/app/com64/libutils.so”(“/ vendor/lib64/libutils.so”)所需或由“/data/app/com.arai.arai-1/lib/arm64/libjnind4jcpu.so”所需的库是命名空间无法访问:[name =“classloader-namespace”,ld_library_paths =“”,default_library_paths =“/ data / app / com.arai.arai-1 / lib / arm64:/ system / fake-libs64:/ data / !应用程序/ com.arai.arai-1 / base.apk / lib目录/ arm64-V8A:/data/app/com.arai.arai-1/split_lib_dependencies_apk.apk / lib目录/ arm64-V8A:/数据/应用/ com.arai.arai-1 / split_lib_slice_0_apk.apk / lib目录/ arm64-V8A:!/data/app/com.arai.arai-1/split_lib_slice_1_apk.apk / lib目录/ arm64-V8A:/数据/应用/ COM . !arai.arai-1 / split_lib_slice_2_apk.apk / lib目录/ arm64-V8A:/data/app/com.arai.arai-1/split_lib_slice_3_apk.apk / lib目录/ arm64-V8A:/data/app/com.arai . !新井-1 / split_lib_slice_4_apk.apk / lib目录/ arm64-V8A:/data/app/com.arai.arai-1/split_lib_slice_5_apk.apk / lib目录/ arm64-V8A:/data/app/com.arai.arai- !1 / split_lib_slice_6_apk.apk / lib目录/ arm64-V8A:/data/app/com.arai.arai-1/split_lib_slice_7_apk.apk / lib目录/ arm64-V8A:/data/app/com.arai.arai-1/分裂_lib_slice_8_apk.apk!/ l W / linker:库“/system/lib64/libbinder.so”(“/ system / lib64 / libbinder.so”)需要或者是“/data/app/com.arai.arai-1”名称空间“classloader-namespace”无法访问/lib/arm64/libjnind4jcpu.so“ - 临时授予访问权限作为http:// b / 26394120的变通方法,请注意在将来的Android版本中将删除访问权限 . E / linker:库“/vendor/lib64/libnativeloader.so”(“/ vendor/lib64/libnativeloader.so”)需要或者是“/data/app/com.arai.arai-1/lib/arm64/libjnind4jcpu” .so“无法访问命名空间:[name =”classloader-namespace“,ld_library_paths =”“,default_library_paths =”/ data / app / com.arai.arai-1 / lib / arm64:/ system / fake-libs64 :/data/app/com.arai.arai-1/base.apk / lib目录/ arm64-V8A:!/data/app/com.arai.arai-1/split_lib_dependencies_apk.apk / lib目录/ arm64-V8A:/ !数据/应用/ com.arai.arai-1 / split_lib_slice_0_apk.apk / lib目录/ arm64-V8A:/data/app/com.arai.arai-1/split_lib_slice_1_apk.apk / lib目录/ arm64-V8A:/数据/ !应用程序/ com.arai.arai-1 / split_lib_slice_2_apk.apk / lib目录/ arm64-V8A:/data/app/com.arai.arai-1/split_lib_slice_3_apk.apk / lib目录/ arm64-V8A:/数据/应用/ com.arai.arai-1 / split_lib_slice_4_apk.apk / lib目录/ arm64-V8A:!/data/app/com.arai.arai-1/split_lib_slice_5_apk.apk / lib目录/ arm64-V8A:/数据/应用/ COM . !arai.arai-1 / split_lib_slice_6_apk.apk / lib目录/ arm64-V8A:/data/app/com.arai.arai-1/split_lib_slice_7_apk.apk / lib目录/ arm64-V8A:/数据/ A pp / com.arai.arai-1 / split_lib_slic W / linker:库“/system/lib64/libandroid_runtime.so”(“/ system / lib64 / libandroid_runtime.so”)需要或者以“/ data / app / com”为例 . 命名空间“classloader-namespace”无法访问arai.arai-1 / lib / arm64 / libjnind4jcpu.so“ - 临时授予访问权限作为http:// b / 26394120的变通方法,请注意该访问权限将被删除在Android的未来版本中 .

Version of Android: API >= 24

Extract from build.gradle, where ND4J dependencies are set:

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"

    defaultConfig {
        applicationId "com.arai.arai"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

        javaCompileOptions {
        annotationProcessorOptions {
            includeCompileClasspath false
        }
        }


    buildTypes {
        release {
            minifyEnabled true
        shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    buildscript {
    configurations.all {
        resolutionStrategy {
            force 'net.sf.proguard:proguard-gradle:5.3.2'
        }
    }
    }

     packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/INDEX.LIST'

    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:27.1.0'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.android.support:design:27.1.0'

    compile (group: 'org.deeplearning4j', name: 'deeplearning4j-core', version: '1.0.0-beta2') {
    exclude group: 'org.bytedeco.javacpp-presets', module: 'opencv-platform'
    exclude group: 'org.bytedeco.javacpp-presets', module: 'leptonica-platform'
    exclude group: 'org.bytedeco.javacpp-presets', module: 'hdf5-platform'
    }      
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2'
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-arm"
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-arm64"
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-x86"
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-x86_64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2'
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-arm"
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-arm64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-x86"
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-x86_64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2'
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-arm"
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-arm64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-x86"
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-x86_64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2'
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-arm"
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-arm64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-x86"
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-x86_64"

    implementation 'com.google.code.gson:gson:2.8.2'
    annotationProcessor 'org.projectlombok:lombok:1.16.16'

    implementation 'com.google.code.findbugs:annotations:3.0.1', {
        exclude module: 'jsr305'
        exclude module: 'jcip-annotations'
    }

    //This corrects for a junit version conflict.
    configurations.all {
        resolutionStrategy.force 'junit:junit:4.12'
    }

}}

回答(0)