I am trying to create a utility function to create a 2-dimensional array of doubles out of a 2-dimensional array of Integers (which is created from deeplearning4j's KerasTokenizer's textsToSequences(String[] texts) method). I created the method below but keep getting NullPointerExceptions
at line 111 (doubles[i][j] = list.get(j);
). How can I change my method or create a new one to fix this problem?
public static double[][] integerToDoubleArray(Integer[][] integers) {
double[][] doubles = new double[integers.length][];
for (int i = 0; i < integers.length; i++) {
List<Integer> list = Arrays.asList(integers[i]);
for (int j = 0; j < list.size(); j++) {
doubles[i][j] = list.get(j);
}
}
return doubles;
}
I call it using the following method with the following API: https://deeplearning4j.org/api/latest/org/deeplearning4j/nn/modelimport/keras/preprocessing/text/KerasTokenizer.html#textsToSequences-java.lang.String:A-
private static double[][] encodeSequences(KerasTokenizer tokenizer, int length, ArrayList<String> sentences) {
return integerToDoubleArray(tokenizer.textsToSequences(arraylistToArray(sentences)));
}