Hi everyone
I’m pretty new to dl4j and just getting started. I want to build a simple example where the input is a Map<Double, Double>, with the first Double being the feature/input (100 random number between 0 and 100), and the second Double being the target (1 if the input is >50, 0 otherwise).
But I can’t seem to produce an Iterator over the Data. Here’s what I’ve tried:
public static DataSetIterator fromEntriesToDataSet(Map<Double, Double> entries) {
final Double[] boxedDoubles = entries.keySet().toArray(new Double[entries.size()]);
final double[] unboxedDoubles = Stream.of(boxedDoubles).mapToDouble(Double::doubleValue).toArray();
INDArray inputNDArray = Nd4j.create(unboxedDoubles);
final Double[] bools = entries.values().toArray(new Double[entries.size()]);
INDArray outPut = Nd4j.create(Arrays.asList(bools));
DataSet dataSet = new DataSet(inputNDArray, outPut);
List<DataSet> listDs = dataSet.asList(); //Cannot convert to list: feature set rank must be in range 2 to 5 inclusive. Got shape: [100]
return new ListDataSetIterator<>(listDs, entries.size());
}
As you can see from the comment, it fails to convert the DataSet to a List, saying it’s got the wrong rank. What am I doing wrong?
Of course, if there’s an easier way to get an Iterator I’m all ears too. I just saw from examples that they usually put the data into INDArray s, and that these need arrays, so I figured I had to convert the data that way.