Skip to content

Instantly share code, notes, and snippets.

@andrewclegg
Created June 17, 2016 13:22
Show Gist options
  • Save andrewclegg/a4f9db8033e8d10dcdf1194b7979a568 to your computer and use it in GitHub Desktop.
Save andrewclegg/a4f9db8033e8d10dcdf1194b7979a568 to your computer and use it in GitHub Desktop.
def buildNetwork(features: Int) = {
val builder = new NeuralNetConfiguration.Builder()
.seed(1)
.iterations(1)
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
.l1(0.1)
.updater(Updater.NONE)
builder.setUseRegularization(true)
val conf = builder
.list
.layer(0, new OutputLayer.Builder(LossFunction.NEGATIVELOGLIKELIHOOD)
.weightInit(WeightInit.XAVIER)
.activation("softmax").weightInit(WeightInit.XAVIER)
.nIn(features).nOut(2).build())
.pretrain(false).backprop(true).build
val network = new MultiLayerNetwork(conf)
network.init()
network.setListeners(Collections.singletonList[IterationListener](new ScoreIterationListener(1)))
network
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment