1

want to adapt deeplearning4j example of UCISequenceClassification: https://github.com/eclipse/deeplearning4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/quickstart/modeling/recurrent/UCISequenceClassification.java. The example contains one feature with one label. I want to use that example in another project in exactly same way, but... with an additional feature. So I tried to add a feature (just for the example: with constant value 1 which I added to code). I tried multiple ways without success. Does anyone know how to add a feature? I assume I has to choose another SequenceRecordReader? Here my first try:

Manipulate Input - Replace this:

 for (String line : lines) {
        String transposed = line.replaceAll(" +", "\n"); // HERE WILL BE THE CHANGE(!!!)

        //Labels: first 100 quickstartexamples (lines) are label 0, second 100 quickstartexamples are label 1, and so on
        contentAndLabels.add(new Pair<>(transposed, lineCount++ / 100));
    }

Manipulate inputs (add one feature) - By this:

 for (String line : lines) {
        String transposed = line.replaceAll(" +", "|1\n"); // HERE IS THE CHANGE(!!!). I ADD VALUE 1

        //Labels: first 100 quickstartexamples (lines) are label 0, second 100 quickstartexamples are label 1, and so on
        contentAndLabels.add(new Pair<>(transposed, lineCount++ / 100));
    }

Now my try to add the feature: Original:

SequenceRecordReader trainFeatures = new CSVSequenceRecordReader();       
trainFeatures.initialize(new NumberedFileInputSplit(featuresDirTrain.getAbsolutePath() + "/%d.csv", 0, 449));

My change:

SequenceRecordReader trainFeatures2 = new CSVMultiSequenceRecordReader("|",Mode.EQUAL_LENGTH); 
trainFeatures2.initialize(new NumberedFileInputSplit(featuresDirTrain.getAbsolutePath() + "/%d.csv", 0, 449));

Unfortunatelly this does not work, because he is not building the dataset in correct form.

So main question I need to solve: How to change SequenceRecordReader to include a second or multiple features? Maybe using another Reader instead of CSVMultiSequenceRecordReader? Or wrong usage?

Thanks for any hints.

(Hint: Please no comment about the static value 1 :-). This should just represanting my example. It will be replaced by another int value which make sense)

Dr. Snoopy
  • 55,122
  • 7
  • 121
  • 140
Corius
  • 9
  • 1

1 Answers1

0

Another feature will depend on which record reader implementation you're using. In your case you're using a csv which means each feature is represented as a column in the CSV. Labels are similar.

You can read our docs here on a more comprehensive overview of the topic: https://deeplearning4j.konduit.ai/deeplearning4j/reference/recurrent-layers

In summary, each file represents a time series. Each column in that file represents a feature. You will need to do the same for labels.

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