Bad INDArray creation performance using DeepLearning4J

161 views Asked by At

As part of a larger piece of code, I am using this

INDArray imageArray = Nd4j.create(rgbValues);

to create my input array for getting an output from my already-trained neural network. rgbValues is a single-dimensional array of approximately 10,000 floats. This one line of code takes about 3 seconds to run, and I'm not sure why. Any help with this is appreciated.

1

There are 1 answers

0
Adam Gibson On

We answered this in gitter but I will answer here for posterity. Use datavec: http://deeplearning4j.org/DataVec

We have our NativeImageLoader which uses javacv under the covers. See: https://github.com/deeplearning4j/dl4j-examples/blob/e15a0d2a87d0a203a5c202c44e6c1e9379a15e10/dl4j-examples/src/main/java/org/deeplearning4j/examples/dataExamples/MnistImagePipelineLoadChooser.java for example usage.