Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
  2. .seed(seed)
  3. .weightInit(WeightInit.XAVIER)
  4. .dist(new NormalDistribution(0.0, 0.01))
  5. .activation(Activation.RELU)
  6. .updater(Updater.NESTEROVS)
  7. .iterations(iterations)
  8. .gradientNormalization(GradientNormalization.RenormalizeL2PerLayer) // normalize to prevent vanishing or exploding gradients
  9. .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
  10. .learningRate(1e-2)
  11. .biasLearningRate(1e-2*2)
  12. .learningRateDecayPolicy(LearningRatePolicy.Step)
  13. .lrPolicyDecayRate(0.1)
  14. .lrPolicySteps(100000)
  15. .regularization(true)
  16. .l2(5 * 1e-4)
  17. .momentum(0.9)
  18. .miniBatch(false)
  19. .list()
  20. .layer(0, convInit("cnn1", channels, 96, new int[]{11, 11}, new int[]{4, 4}, new int[]{3, 3}, 0))
  21. .layer(1, new LocalResponseNormalization.Builder().name("lrn1").build())
  22. .layer(2, maxPool("maxpool1", new int[]{3,3}))
  23. .layer(3, conv5x5("cnn2", 256, new int[] {1,1}, new int[] {2,2}, nonZeroBias))
  24. .layer(4, new LocalResponseNormalization.Builder().name("lrn2").build())
  25. .layer(5, maxPool("maxpool2", new int[]{3,3}))
  26. .layer(6,conv3x3("cnn3", 384, 0))
  27. .layer(7,conv3x3("cnn4", 384, nonZeroBias))
  28. .layer(8,conv3x3("cnn5", 256, nonZeroBias))
  29. .layer(9, maxPool("maxpool3", new int[]{3,3}))
  30. .layer(10, fullyConnected("ffn1", 4096, nonZeroBias, dropOut))
  31. .layer(11, fullyConnected("ffn2", 4096, nonZeroBias, dropOut))
  32. .layer(12, new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD)
  33. .name("output")
  34. .nOut(numLabels)
  35. .activation(Activation.SOFTMAX)
  36. .build())
  37. .backprop(true)
  38. .pretrain(false)
  39. .setInputType(InputType.convolutional(height, width, channels))
  40. .build();
  41.  
  42.  
  43. private DenseLayer fullyConnected(String name, int out, double bias, double dropOut) {
  44. return new DenseLayer.Builder().name(name).nOut(out).biasInit(bias).dropOut(dropOut).build();
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement