Skip to content

Instantly share code, notes, and snippets.

@Shmuma
Created October 15, 2015 11:03
Show Gist options
  • Select an option

  • Save Shmuma/1a590002ee8c22eca5ad to your computer and use it in GitHub Desktop.

Select an option

Save Shmuma/1a590002ee8c22eca5ad to your computer and use it in GitHub Desktop.
public static MultiLayerNetwork createRBMModel(int iterations, int features, int hidden) {
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
.seed(123)
.iterations(iterations)
.learningRate(1e-1)
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
.constrainGradientToUnitNorm(true)
.momentum(0.9)
.list(2)
.layer(0, new RBM.Builder(RBM.HiddenUnit.RECTIFIED, RBM.VisibleUnit.GAUSSIAN)
.nIn(features)
.nOut(hidden)
.weightInit(WeightInit.XAVIER)
.k(1)
.activation("relu")
.lossFunction(LossFunctions.LossFunction.MSE)
.build())
.layer(1, new OutputLayer.Builder(LossFunctions.LossFunction.MSE)
.nIn(hidden)
.nOut(1)
.activation("identity")
.build()
)
.build();
return new MultiLayerNetwork(conf);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment