【问题标题】:deeplearning4j embedding more than one fielddeeplearning4j 嵌入多个字段
【发布时间】:2020-06-24 08:05:56
【问题描述】:

如何在 deeplearning4j 中嵌入多个字段?

例如,如果我想将user_idad_id 嵌入为两个字段:

 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

此代码仅在 deeplearning4j 中嵌入了一个字段。如何一次嵌入多个?

【问题讨论】:

    标签: apache-spark machine-learning embedding deeplearning4j


    【解决方案1】:

    在这种情况下,您将使用基于 ComputationGraph 的网络。一个 ComputationGraph 可以有多个输入,这将允许您在开始时使用多个嵌入层。

    有关更多信息,请查看文档: https://deeplearning4j.konduit.ai/models/computationgraph#example-2-multiple-inputs-and-merge-vertex

    【讨论】:

    • 谢谢你的回答,但它需要多数据集进行训练(多输入是一个热点功能),如何构造多数据集?
    猜你喜欢
    • 2010-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-06
    • 2021-11-04
    • 1970-01-01
    相关资源
    最近更新 更多