- Create ImagePreProcessingScaler for image normalization:
DataNormalization scaler = new ImagePreProcessingScaler(0,1);
- Create a neural network configuration and add default hyperparameters:
MultiLayerConfiguration.Builder builder = new NeuralNetConfiguration.Builder().weightInit(WeightInit.DISTRIBUTION)
.dist(new NormalDistribution(0.0, 0.01))
.activation(Activation.RELU)
.updater(new Nesterovs(new StepSchedule(ScheduleType.ITERATION, 1e-2, 0.1, 100000), 0.9))
.biasUpdater(new Nesterovs(new StepSchedule(ScheduleType.ITERATION, 2e-2, 0.1, 100000), 0.9))
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer) // normalize to prevent vanishing or exploding gradients
.l2(l2RegularizationParam)
.list();
- Create convolution layers for a CNN using ConvolutionLayer:
builder.layer(new ConvolutionLayer.Builder(11,11)
.nIn(channels)
.nOut(96)
.stride(1,1)
.activation(Activation.RELU)
.build());
- Configure subsampling layers using SubsamplingLayer:
builder.layer(new SubsamplingLayer.Builder(PoolingType.MAX)
.kernelSize(kernelSize,kernelSize)
.build());
- Normalize activation between layers using LocalResponseNormalization:
builder.layer(1, new LocalResponseNormalization.Builder().name("lrn1").build());