Search code examples
deep-learningneural-networkdeeplearning4j

Create a DataSet with multiple labels and unknown number of classes in deeplearning4j


What DataSetIterator should I use in order to create a DataSet object that contains miultiple features and labels? I have only seen examples similar to 'Iris example' where there is only one label and it is known how many different labels there are. In my problem there are four labels (position X, position Y, width and height of a shape) and many features (pixels values) and it's impossible to calculate how many different labels there could be.

I want something like this

RecordReader recordReader = new CSVRecordReader(0, ',');
recordReader.initialize(new FileSplit(new File(fileName)));

DataSetIterator iterator = new CustomDataSetIterator(recordReader, numRows, numFeatures, numLables);
DataSet allData = iterator.next();

Using data that looks like this

feature0;feature1;feature2;feature3;label0;label1;

I know that this question seems very basic and it is but I really had hard time finding any information about this topic in official tutorials or in documentation.


Solution

  • it seems like you are looking for an object detection kind of data with bounding boxes an multiple possible objects in your picture.

    take a look at this example for that: https://github.com/eclipse/deeplearning4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/convolution/objectdetection/HouseNumberDetection.java

    in general there is a MultiDataSet that can take multiple inputs and can have multiple outputs.