Initializers
Mapping of Keras weight initializers to DL4J WeightInit implementations for model import in Eclipse Deeplearning4j 1.0.0-M2.1.
Last updated
Was this helpful?
Was this helpful?
// Keras: kernel_initializer='zeros'
// DL4J:
.weightInit(WeightInit.ZERO)// Keras: kernel_initializer=Constant(value=0.1)
// DL4J (via IWeightInit):
.weightInit(new WeightInitConst(0.1))// Keras: kernel_initializer=RandomNormal(mean=0.0, stddev=0.05)
// DL4J:
.weightInit(WeightInit.NORMAL)
// Std dev can be configured via distribution:
.dist(new NormalDistribution(0.0, 0.05))// Keras: kernel_initializer=RandomUniform(minval=-0.05, maxval=0.05)
// DL4J:
.weightInit(WeightInit.UNIFORM)
.dist(new UniformDistribution(-0.05, 0.05))// Keras: kernel_initializer='truncated_normal'
// DL4J:
.weightInit(WeightInit.TRUNCATED_NORMAL)// glorot_uniform (default in many Keras layers)
.weightInit(WeightInit.XAVIER_UNIFORM)
// glorot_normal
.weightInit(WeightInit.XAVIER)// he_normal
.weightInit(WeightInit.RELU)
// he_uniform
.weightInit(WeightInit.RELU_UNIFORM)import org.deeplearning4j.nn.modelimport.keras.KerasModelImport;
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
// Weight initializers are automatically mapped during import.
// If the model has already been trained and weights are saved, the
// initializer config is informational only — actual weights are loaded
// from the HDF5 file.
MultiLayerNetwork model = KerasModelImport.importKerasSequentialModelAndWeights("model.h5");