how to structure multidataset format to train ComputationGraph in deeplearning4j?

The ComputationGraph as follows:

val conf = new NeuralNetConfiguration.Builder()
.seed(12345) 
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
.iterations(1) 
.activation(Activation.LEAKYRELU) 
.weightInit(WeightInit.XAVIER) 
.learningRate(0.01) 
.updater(Updater.NESTEROVS)
.momentum(0.9) 
.regularization(true)
.l2(1e-4) 
.graphBuilder() 
.addInputs("userid","weekday","hour","isworkday") 
.addLayer("L1", new EmbeddingLayer.Builder().nOut(512).activation(Activation.IDENTITY).build(),"ip")
.addVertex("merge",new MergeVertex(), "L1", "adid","appid","createtype","height","width","weekday","hour","isworkday") 
.addLayer("L2", new DenseLayer.Builder().nOut(10).build,"merge") 
.addLayer("out", new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD) .activation(Activation.SOFTMAX) .nIn(10).nOut(1).build,"L2") 
.setOutputs("out")

how to structure multidataset data format to train ComputationGraph in deeplearning4j from spark dataframe data? “weekday”,“hour”,“isworkday” through onehot encoder feature,“userid” through embedding feature,

There are multiple things to note here:

  1. I guess you didn’t quite finish your post?
  2. It appears you are using a very old version of DL4J. Things like .iterations have been removed from the Network configuration a few versions ago.
  3. The configuration of your Graph is all wrong. If you really want to have everything as a single input, you have to actually list everything that is going to be an input in addInputs. In your addVertex("merge", ...) line, you have listed things that were not listed as part of the inputs, nor are they produced by other layers.
  4. Typically, you wouldn’t want to have an input per feature of your data. It makes your network definition needlessly complex. Instead you want to vectorize your data appropriately. To learn how to do that, I suggest you take a look at https://www.dubs.tech/guides/quickstart-with-dl4j/#loading-data first, and then dive into the datavec documentation

In general, a MultiDataSet will take an array of INDArray instances for features and datasets each. The mapping between the entries in those arrays and the names in your ComputationGraph is the their order. This means, that the INDArray in your MultiDataSet features will be matched to the first input of your ComputationGraph, and the same applies to the outputs, the first INDArray in your MultiDataSet labels will be matched to the first output defined in your ComputationGraph.

1 Like

thank you for your answer, the version of DL4J is 0.8 ,it exactly old,now i use 1.0.0-beta5,and the configuration of my Graph is wrong in addvertex,I just want to express the multi input model need computation graph to solve, the computation graph need MultiDataSet to fit (like sparkNet.fitMultiDataSet()),but i do not how to strcture the MultiDataSet to fit the computation graph,
i understand your mean is that " userid",“weekday”,“hour”,“isworkday” each field save to INDArray and combine to an array of INDArray? for this,i not familiar with it ,can you help me to solve it? It would be better to give me an example.

Beta5 is still quite old. The latest release is beta7.

I already linked you to an example where multiple input columns are combined into a single INDArray: https://www.dubs.tech/guides/quickstart-with-dl4j/#loading-data

Everything else should be already answered in my previous answer.

Unfortunately, I don’t have the time to provide examples for every possible situation. You will have to try to work it out and ask precise questions about the things where you struggle - ideally with the exact code you are using.