Train a neural network on mobile with DL4J?

I am new to DL4J and plan to train small neural networks from scratch on mobile devices, especially on Android. While the inference on mobile is nowadays quite popular, there seem to be only a few frameworks, such as Tensorflow Lite and CoreML which actually allow to train a network on mobile devices.

I cannot find any examples or tutorials to do this with DL4J. Is it in general possible or not? I would be grateful for your experiences or thoughts.

@Plumbum you can train on mobile devices but it’s not encouraged unless it’s a small batch size. Mobile processors just aren’t fit for that.

If you just look at it from a user’s perspective they wouldnt’ want an app on their phone taking up all the ram/cpu for training. Could you clarify your use case?

We have jars for android an example here: deeplearning4j-examples/android-examples at master · deeplearning4j/deeplearning4j-examples · GitHub

It needs to be updated a bit. I’ve had reported issues I can’t reproduce on neither my phone or emulator. If you want to try it let me know.

So…in summary yes but in specific cases. If the math code runs and inference runs then of course training will run, whether you should is a different matter though.

@agibsonccc thank you for your fast response and the provided example.

@Plumbum of course. Just try to be pragmatic about what you should/shouldn’t do.

Running a whole training process on a phone is not recommended. You have to carefully manage state
(which some folks I don’t think are prepared to do from some previous conversations I’ve had)

One other problem I’ve seen people run in to is state management of the model. If you load the model from disk every time the app starts you’ll spend most of your time loading from disk which might take a minute.