0

I need a very basic classification or similar example for deeplearning4j framework.

I have the classic training set in form of pairs of already normalized double arrays [0.01, 0.45, 0.0, ....] -> [0.0, 0.1, 0.0, 0.0, ...] and need to:

  1. Build and train a simple feedforward neural network with N hidden layers
  2. Feed a set of uncategorized double arrays to trained network and get a set of output vectors

Could somebody please share a basic and short example that does this?

UPD: Something like this but for deeplearning4j would really help.

Sogawa-sps
  • 147
  • 10
  • Hi, you can find more than enough here: https://github.com/eclipse/deeplearning4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/dataexamples/BasicCSVClassifier.java and in the parent folder: https://github.com/eclipse/deeplearning4j-examples/tree/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/dataexamples You haven't given enough details (like what kind of normalization) to give you more help than that. Keep in mind, you should have some basic knowledge before going in to this too much. – Adam Gibson Jan 27 '20 at 00:46
  • Hi Adam! I'm migrating from Encog and some sample like this would help https://github.com/jeffheaton/encog-java-examples/blob/master/src/main/java/org/encog/examples/neural/predict/sunspot/PredictSunspot.java It's not a classification example but it clearly demonstrates how to quickly create working feedforward prototype in jump-start mode. So if you can advise something like that it would be great. – Sogawa-sps Jan 27 '20 at 02:40
  • Thank you for advising! I've already gave a look to these official examples but it looks like all of them "too fancy" didn't spot anything that starts with old good plain numbers :). Of course they will help as well, so I would start with that samples if I din't find anything else. – Sogawa-sps Jan 27 '20 at 02:44
  • Hmm generally, the examples are targeting normal real world use cases like: Load data from external source, put in to model. Typically, people don't create double arrays and train models. – Adam Gibson Jan 27 '20 at 05:02

1 Answers1

0

Take a look at this example which shows how to train a nn on an XOR relationship. First you have to convert your doubles into ndarrays. To do this use the Nd4j.create(...) method. Then you need to set up a dataset like here.

Susan Eraly
  • 339
  • 1
  • 7
  • Could you please advise is there a fast way to convert INDArray output (INDArray output = net.output(input);) back into double arrays? – Sogawa-sps Jan 28 '20 at 19:15
  • 1
    use output.toDoubleMatrix() or output.toDoubleVector() – wm_eddie Jan 29 '20 at 13:49
  • Link no longer exists at the official repository. You can use `wmeddie`'s repository: [Xor example](https://github.com/wmeddie/dl4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/feedforward/xor/XorExample.java) – lepe Feb 10 '21 at 02:29