0

How can I embed more than one field in deeplearning4j?

For example, if I want to embed user_id and ad_id as two fields:

 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)
  .list
  .layer(0, new EmbeddingLayer.Builder().nIn(FEATURE_DIMS).nOut(512).activation(Activation.IDENTITY).build())
  .layer(1, new DenseLayer.Builder().nIn(512).nOut(10).build)
  .layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD)
    .activation(Activation.SOFTMAX)
    .nIn(10).nOut(1).build)
  .pretrain(false)
  .backprop(true)
  .build

This code only embeds one field in deeplearning4j. How can I embed more than one at a time?

AlBlue
  • 23,254
  • 14
  • 71
  • 91

1 Answers1

0

In that case you will be using a ComputationGraph based network. A ComputationGraph can have multiple inputs, and that would allow you to use multiple Embedding Layers at the beginning.

For more on that take a look at the documentation: https://deeplearning4j.konduit.ai/models/computationgraph#example-2-multiple-inputs-and-merge-vertex

Paul Dubs
  • 798
  • 4
  • 8
  • thank you for your answer,but it need multidataset for train(multi inputs is onehot feature),how to structure the multidataset? – 晨钟暮鼓 Jun 28 '20 at 02:36