# DL4J on Android

**URL:** <https://community.konduit.ai/t/dl4j-on-android/958>\
**Category:** DL4J\
**Created:** [November 1, 2020, 4:32am UTC](https://community.konduit.ai/t/dl4j-on-android/958 "2020-11-01T04:32:40Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![achan021](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@achan021](https://community.konduit.ai/u/achan021)\
**Post date:** [November 1, 2020, 4:32am UTC](https://community.konduit.ai/t/dl4j-on-android/958/1 "2020-11-01T04:32:40Z")

</div>

Hi everyone, I am trying to import my keras model over to DL4J on android. However, I am stuck with “Platform “android-arm64” not supported by class org.bytedeco.javacpp.hdf5”. Is there a workaround to this? If not would anyone kindly advise me on alternatives that will allow me to import a python model and perform training on android? Thank you sooo much in advance

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [November 2, 2020, 1:44am UTC](https://community.konduit.ai/t/dl4j-on-android/958/2 "2020-11-02T01:44:18Z")

</div>

@saudet can help you here

---

<div class="post-metadata">

**Author:** ![saudet](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/saudet/32/69_2.png) [@saudet](https://community.konduit.ai/u/saudet)\
**Post date:** [November 2, 2020, 2:14am UTC](https://community.konduit.ai/t/dl4j-on-android/958/3 "2020-11-02T02:14:46Z")

</div>

Import the model from your development machine.

---

<div class="post-metadata">

**Author:** ![achan021](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@achan021](https://community.konduit.ai/u/achan021)\
**Post date:** [November 2, 2020, 2:43am UTC](https://community.konduit.ai/t/dl4j-on-android/958/4 "2020-11-02T02:43:52Z")

</div>

Unfortunately that was what threw the error that i mentioned previously on android studio using the DL4J dependency.

---

<div class="post-metadata">

**Author:** ![saudet](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/saudet/32/69_2.png) [@saudet](https://community.konduit.ai/u/saudet)\
**Post date:** [November 2, 2020, 2:55am UTC](https://community.konduit.ai/t/dl4j-on-android/958/5 "2020-11-02T02:55:23Z")

</div>

“android-arm64” → That’s not your development machine. You’ll need a Linux, Mac, or Windows machine to develop applications for Android.

---

<div class="post-metadata">

**Author:** ![achan021](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@achan021](https://community.konduit.ai/u/achan021)\
**Post date:** [November 2, 2020, 3:07am UTC](https://community.konduit.ai/t/dl4j-on-android/958/6 "2020-11-02T03:07:01Z")

</div>

ahh i get what you mean. But is there no way to import it locally on the android app?

---

<div class="post-metadata">

**Author:** ![saudet](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/saudet/32/69_2.png) [@saudet](https://community.konduit.ai/u/saudet)\
**Post date:** [November 2, 2020, 3:19am UTC](https://community.konduit.ai/t/dl4j-on-android/958/7 "2020-11-02T03:19:17Z")

</div>

If you need to do that, please explain why you need to do that. There is probably a better way of doing what you’re doing.

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [November 2, 2020, 3:32am UTC](https://community.konduit.ai/t/dl4j-on-android/958/8 "2020-11-02T03:32:27Z")

</div>

In this case, I agree with @saudet if all you want to do is import a model, resaving in on another machine doesn’t really affect your workflow. Setup a util class that manages this process, document it in a readme, move on? It’s not like you’re running a python training workflow on your android phone.

---

<div class="post-metadata">

**Author:** ![achan021](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@achan021](https://community.konduit.ai/u/achan021)\
**Post date:** [November 2, 2020, 6:26am UTC](https://community.konduit.ai/t/dl4j-on-android/958/9 "2020-11-02T06:26:37Z")

</div>

Oh I am exploring ways to perform federated learning on a mobile. However, because I am more familiar with model creation using python, I want to export my python model over to my android to perform training on the device before sending the model back to the development machine for aggregation.

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [November 2, 2020, 6:28am UTC](https://community.konduit.ai/t/dl4j-on-android/958/10 "2020-11-02T06:28:36Z")

</div>

@achan021 it’s a bit old, but someone did this a few years back:

> **[GitHub - mccorby/FederatedAndroidTrainer: See new version...](https://github.com/mccorby/FederatedAndroidTrainer)**
>
> See new version https://github.com/mccorby/PhotoLabeller - GitHub - mccorby/FederatedAndroidTrainer: See new version https://github.com/mccorby/PhotoLabeller

Even with model import, you’ll have to update your model using java/kotlin anyways.  
All you would have to do is run a sub process that uses dl4j to export the model and then load it on mobile. You could do that in the same process. It’d be 1 or 2 lines of java code.

---

<div class="post-metadata">

**Author:** ![achan021](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@achan021](https://community.konduit.ai/u/achan021)\
**Post date:** [November 2, 2020, 6:50am UTC](https://community.konduit.ai/t/dl4j-on-android/958/11 "2020-11-02T06:50:13Z")

</div>

ahh so just to make sure that I am getting you correctly. I can convert my python model to DL4J format before exporting to the mobile platform, is that correct?

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [November 2, 2020, 7:01am UTC](https://community.konduit.ai/t/dl4j-on-android/958/12 "2020-11-02T07:01:31Z")

</div>

@achan021 yes that’s all you’d have to do. That’s what @saudet suggested as well:  
train model → import in to dl4j → run on device load using dl4j.

The only thing that’s missing is running hdf5 on mobile is a bit obnoxious. It’s mainly supported on desktop OSes.

When the work around is fairly straightforward, there’s not a lot of ROI in trying to make that work.

---

<div class="post-metadata">

**Author:** ![achan021](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@achan021](https://community.konduit.ai/u/achan021)\
**Post date:** [November 2, 2020, 7:13am UTC](https://community.konduit.ai/t/dl4j-on-android/958/13 "2020-11-02T07:13:35Z")

</div>

Ahh I see, what about the conversion from DL4J format to possible keras model. Does DL4J support that feature?

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [November 2, 2020, 8:17am UTC](https://community.konduit.ai/t/dl4j-on-android/958/14 "2020-11-02T08:17:42Z")

</div>

@achan021 not directly, but it’s straightforward to export weights and load them in keras. We allow writing numpy arrays.

---

<div class="post-metadata">

**Author:** ![achan021](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@achan021](https://community.konduit.ai/u/achan021)\
**Post date:** [November 2, 2020, 8:23am UTC](https://community.konduit.ai/t/dl4j-on-android/958/15 "2020-11-02T08:23:13Z")

</div>

Alright, thank you soo much for your time!!
