javaneural-networkdeeplearning4jnd4j

Deeplearning4j: Generate random INDArray(s) as input for a MultiLayerNetwork


I am working on a project where I intend to do some performance analysis on MultiLayerNetworks. As the title says it, I intend to create a random INDArray of inputs and labels of arbitrary size, which will be used as (training-)input for an arbitrary MultiLayerNetwork. To be perhaps more precise, I want to generate inputs suitable for any given MultiLayerNetwork. I tried using Nd4j.rand and Nd4j.zeros to generate inputs and labels for the network, however as far as I understand, different layers have different shape requirements. Any help/advice is much appreciated. Thanks in advance!

Note: I am not interested in the data itself, or the outcomes: Generating random data is enough in my case.


Solution

  • What you're looking for isn't really a "thing". You would have to enumerate different architectures. While you can determine valid inputs based on shape, those are still ndarrays you would have to create yourself. Your bet bet would be to constrain the problem and iterating over a deterministic set of input sizes. This is how we create test cases in dl4j itself.

    Note: There are "fancier" methods along the lines of hyper parameter search, but even then you're still just generating random candidates and enumerating over a set of inputs. For just 2d dense nets you can determine what's valid based on the number of inputs being equal to the number of outputs of the previous layer for example.

    Once you get beyond that you start getting in to figuring out what combinations of layers are valid + being able to determine how many layers deep you want the net to be.