Source:
public KerasEmbedding(Map<String, Object> layerConfig, boolean enforceTrainingConfig) throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException { super(layerConfig, enforceTrainingConfig); int inputDim = getInputDimFromConfig(layerConfig); int[] inputShapeOld = this.inputShape; this.inputShape = new int[inputShapeOld.length + 1]; this.inputShape[0] = inputShapeOld[0]; this.inputShape[1] = inputDim; this.hasZeroMasking = KerasLayerUtils.getZeroMaskingFromConfig(layerConfig, conf); if (hasZeroMasking) log.warn("Zero Masking for the Embedding layer only works with unidirectional LSTM for now." + "For Bidirectional layers, you can set the mask yourself."); Pair<WeightInit, Distribution> init = getWeightInitFromConfig(layerConfig, conf.getLAYER_FIELD_EMBEDDING_INIT(), enforceTrainingConfig, conf, kerasMajorVersion); WeightInit weightInit = init.getFirst(); Distribution distribution = init.getSecond(); LayerConstraint embeddingConstraint = KerasConstraintUtils.getConstraintsFromConfig( layerConfig, conf.getLAYER_FIELD_EMBEDDINGS_CONSTRAINT(), conf, kerasMajorVersion); EmbeddingLayer.Builder builder = new EmbeddingLayer.Builder().name(this.layerName).nIn(inputDim) .nOut(getNOutFromConfig(layerConfig, conf)).dropOut(this.dropout).activation(Activation.IDENTITY) .weightInit(weightInit) .biasInit(0.0) .l1(this.weightL1Regularization).l2(this.weightL2Regularization).hasBias(false); if (distribution != null) builder.dist(distribution); if (embeddingConstraint != null) builder.constrainWeights(embeddingConstraint); this.layer = builder.build(); }

Target:
public KerasEmbedding(Map<String, Object> layerConfig, boolean enforceTrainingConfig) throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException { super(layerConfig, enforceTrainingConfig); int inputDim = getInputDimFromConfig(layerConfig); int[] inputShapeOld = this.inputShape; this.inputShape = new int[inputShapeOld.length + 1]; this.inputShape[0] = inputShapeOld[0]; this.inputShape[1] = inputDim; this.hasZeroMasking = KerasLayerUtils.getZeroMaskingFromConfig(layerConfig, conf); if (hasZeroMasking) log.warn("Masking in keras and DL4J work differently. We do not completely support mask_zero flag " + "on Embedding layers. Zero Masking for the Embedding layer only works with unidirectional LSTM for now." + " If you want to have this behaviour for your imported model " + "in DL4J, apply masking as a pre-processing step to your input." + "See <LINK_0> for more on this."); Pair<WeightInit, Distribution> init = getWeightInitFromConfig(layerConfig, conf.getLAYER_FIELD_EMBEDDING_INIT(), enforceTrainingConfig, conf, kerasMajorVersion); WeightInit weightInit = init.getFirst(); Distribution distribution = init.getSecond(); LayerConstraint embeddingConstraint = KerasConstraintUtils.getConstraintsFromConfig( layerConfig, conf.getLAYER_FIELD_EMBEDDINGS_CONSTRAINT(), conf, kerasMajorVersion); EmbeddingLayer.Builder builder = new EmbeddingLayer.Builder().name(this.layerName).nIn(inputDim) .nOut(getNOutFromConfig(layerConfig, conf)).dropOut(this.dropout).activation(Activation.IDENTITY) .weightInit(weightInit) .biasInit(0.0) .l1(this.weightL1Regularization).l2(this.weightL2Regularization).hasBias(false); if (distribution != null) builder.dist(distribution); if (embeddingConstraint != null) builder.constrainWeights(embeddingConstraint); this.layer = builder.build(); }