2

I want to write a RNN in Deeplearning4j for stock market predictions but I'm struggling with creating und filling the 3-dimensional INDArrays. So if I have the following time series:

1 2 3 4 5 6 7 8 9 10

and I want to use 5 values as input and predict the 6th value:

Input: 1 2 3 4 5 TeachingInput: 6

Input: 2 3 4 5 6 TeachingInput: 7

...

I would fill the INDArrays like this:

int numExamples = 5; //1-5, 2-6,..., 5-9
int inputSize = 5; 
int timeSeriesLength = 10;
INDArray features =  Nd4j.create(new int[]{numExamples,inputSize,timeSeriesLength}, 'f');

int outputSize = 1;
INDArray labels =  Nd4j.create(new int[]{numExamples,outputSize,timeSeriesLength}, 'f');

Is this correct? If so, how do the filled INDArrays look like for the features, labels, featuresMask and labelsMask?

Thank you.

marcelovca90
  • 2,673
  • 3
  • 27
  • 34
M. Lohmann
  • 23
  • 3
  • [How do I format my posts using Markdown or HTML?](http://stackoverflow.com/help/formatting) – buhtz Aug 31 '16 at 12:37

1 Answers1

0

You may want to check deeplearning4j.org/usingrnns

If you need to hand roll your own for some reason look at what we do in the sequencerecordreaderdatasetiterator.

I'd highly advise using datavec if you can. We solved this problem for you already.

Check out the https://github.com/deeplearning4j/deeplearning4j/blob/master/deeplearning4j-core/src/main/java/org/deeplearning4j/datasets/datavec/SequenceRecordReaderDataSetIterator.java

internals.

Adam Gibson
  • 3,055
  • 1
  • 10
  • 12