当前位置: 首页>>代码示例>>Java>>正文


Java MultiLayerConfiguration类代码示例

本文整理汇总了Java中org.deeplearning4j.nn.conf.MultiLayerConfiguration的典型用法代码示例。如果您正苦于以下问题:Java MultiLayerConfiguration类的具体用法?Java MultiLayerConfiguration怎么用?Java MultiLayerConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MultiLayerConfiguration类属于org.deeplearning4j.nn.conf包,在下文中一共展示了MultiLayerConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: softMaxRegression

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
private static MultiLayerNetwork softMaxRegression(int seed,
		int iterations, int numRows, int numColumns, int outputNum) {
	MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
			.seed(seed)
			.gradientNormalization(
					GradientNormalization.ClipElementWiseAbsoluteValue)
			.gradientNormalizationThreshold(1.0)
			.iterations(iterations)
			.momentum(0.5)
			.momentumAfter(Collections.singletonMap(3, 0.9))
			.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT)
			.list(1)
			.layer(0,
					new OutputLayer.Builder(
							LossFunction.NEGATIVELOGLIKELIHOOD)
							.activation("softmax")
							.nIn(numColumns * numRows).nOut(outputNum)
							.build()).pretrain(true).backprop(false)
			.build();

	MultiLayerNetwork model = new MultiLayerNetwork(conf);

	return model;
}
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:25,代码来源:NeuralNetworks.java

示例2: getDeepDenseLayerNetworkConfiguration

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
/** Returns the network configuration, 2 hidden DenseLayers of size 50.
 */
private static MultiLayerConfiguration getDeepDenseLayerNetworkConfiguration() {
    final int numHiddenNodes = 50;
    return new NeuralNetConfiguration.Builder()
            .seed(seed)
            .iterations(iterations)
            .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
            .learningRate(learningRate)
            .weightInit(WeightInit.XAVIER)
            .updater(Updater.NESTEROVS).momentum(0.9)
            .list()
            .layer(0, new DenseLayer.Builder().nIn(numInputs).nOut(numHiddenNodes)
                    .activation(Activation.TANH).build())
            .layer(1, new DenseLayer.Builder().nIn(numHiddenNodes).nOut(numHiddenNodes)
                    .activation(Activation.TANH).build())
            .layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.MSE)
                    .activation(Activation.IDENTITY)
                    .nIn(numHiddenNodes).nOut(numOutputs).build())
            .pretrain(false).backprop(true).build();
}
 
开发者ID:IsaacChanghau,项目名称:NeuralNetworksLite,代码行数:22,代码来源:RegressionMathFunctions.java

示例3: getConfiguration

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
protected MultiLayerConfiguration getConfiguration()
   {
int hiddenLayerNodes = parameters.getHiddeLayerNodes()[0];
final RBM hiddenLayer = new RBM.Builder(RBM.HiddenUnit.RECTIFIED, RBM.VisibleUnit.GAUSSIAN)
	.nIn(parameters.getInputSize()).nOut(hiddenLayerNodes).weightInit(WeightInit.XAVIER).k(1)
	.activation("relu").lossFunction(LossFunctions.LossFunction.RMSE_XENT).updater(Updater.ADAGRAD)
	.dropOut(0.5).build();

final OutputLayer outputLayer = new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT).nIn(hiddenLayerNodes)
	.nOut(parameters.getOutputSize()).activation("softmax").build();

return new NeuralNetConfiguration.Builder().seed(parameters.getSeed()).iterations(parameters.getIterations())
	.learningRate(parameters.getLearningRate()).optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT)
	.l2(2e-4).regularization(true).momentum(0.9).useDropConnect(true).list(2).layer(0, hiddenLayer)
	.layer(1, outputLayer).build();
   }
 
开发者ID:amrabed,项目名称:DL4J,代码行数:17,代码来源:DeepBeliefNetworkModel.java

示例4: getConfiguration

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
@Override
   protected MultiLayerConfiguration getConfiguration()
   {
return new NeuralNetConfiguration.Builder().seed(parameters.getSeed()).iterations(parameters.getIterations())
	.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).learningRate(parameters.getLearningRate()).l2(0.001)
	.list(4)
	.layer(0,
		new DenseLayer.Builder().nIn(parameters.getInputSize()).nOut(250).weightInit(WeightInit.XAVIER)
			.updater(Updater.ADAGRAD).activation("relu").build())
	.layer(1,
		new DenseLayer.Builder().nIn(250).nOut(10).weightInit(WeightInit.XAVIER)
			.updater(Updater.ADAGRAD).activation("relu").build())
	.layer(2,
		new DenseLayer.Builder().nIn(10).nOut(250).weightInit(WeightInit.XAVIER)
			.updater(Updater.ADAGRAD).activation("relu").build())
	.layer(3,
		new OutputLayer.Builder().nIn(250).nOut(parameters.getInputSize()).weightInit(WeightInit.XAVIER)
			.updater(Updater.ADAGRAD).activation("relu")
			.lossFunction(LossFunctions.LossFunction.MSE).build())
	.pretrain(false).backprop(true).build();
   }
 
开发者ID:amrabed,项目名称:DL4J,代码行数:22,代码来源:AnomalyDetectionModel.java

示例5: getConfiguration

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
@Override
   protected MultiLayerConfiguration getConfiguration()
   {
return new NeuralNetConfiguration.Builder().seed(parameters.getSeed())
	.gradientNormalization(GradientNormalization.ClipElementWiseAbsoluteValue)
	.gradientNormalizationThreshold(1.0).iterations(parameters.getIterations()).momentum(0.5)
	.momentumAfter(Collections.singletonMap(3, 0.9))
	.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT).list(4)
	.layer(0,
		new AutoEncoder.Builder().nIn(parameters.getInputSize()).nOut(500).weightInit(WeightInit.XAVIER)
			.lossFunction(LossFunction.RMSE_XENT).corruptionLevel(0.3).build())
	.layer(1, new AutoEncoder.Builder().nIn(500).nOut(250).weightInit(WeightInit.XAVIER)
		.lossFunction(LossFunction.RMSE_XENT).corruptionLevel(0.3)

		.build())
	.layer(2,
		new AutoEncoder.Builder().nIn(250).nOut(200).weightInit(WeightInit.XAVIER)
			.lossFunction(LossFunction.RMSE_XENT).corruptionLevel(0.3).build())
	.layer(3, new OutputLayer.Builder(LossFunction.NEGATIVELOGLIKELIHOOD).activation("softmax").nIn(200)
		.nOut(parameters.getOutputSize()).build())
	.pretrain(true).backprop(false).build();
   }
 
开发者ID:amrabed,项目名称:DL4J,代码行数:23,代码来源:StackedAutoEncoderModel.java

示例6: getConfiguration

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
@Override
   protected MultiLayerConfiguration getConfiguration()
   {
final ConvulationalNetParameters parameters = (ConvulationalNetParameters) this.parameters;
final MultiLayerConfiguration.Builder builder = new NeuralNetConfiguration.Builder().seed(parameters.getSeed())
	.iterations(parameters.getIterations())
	.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list(2)
	.layer(0,
		new ConvolutionLayer.Builder(new int[] { 1, 1 }).nIn(parameters.getInputSize()).nOut(1000)
			.activation("relu").weightInit(WeightInit.RELU).build())
	.layer(1,
		new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT).nOut(parameters.getOutputSize())
			.weightInit(WeightInit.XAVIER).activation("softmax").build())
	.backprop(true).pretrain(false);

new ConvolutionLayerSetup(builder, parameters.getRows(), parameters.getColumns(), parameters.getChannels());

return builder.build();
   }
 
开发者ID:amrabed,项目名称:DL4J,代码行数:20,代码来源:ConvolutionalNetModel.java

示例7: getConfiguration

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
@Override
   protected MultiLayerConfiguration getConfiguration()
   {
final ConvulationalNetParameters parameters = (ConvulationalNetParameters) this.parameters;
final MultiLayerConfiguration.Builder builder = new NeuralNetConfiguration.Builder().seed(parameters.getSeed())
	.iterations(parameters.getIterations())
	.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer)
	.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list(3)
	.layer(0,
		new ConvolutionLayer.Builder(10, 10).stride(2, 2).nIn(parameters.getChannels()).nOut(6)
			.weightInit(WeightInit.XAVIER).activation("relu").build())
	.layer(1, new SubsamplingLayer.Builder(SubsamplingLayer.PoolingType.MAX, new int[] { 2, 2 }).build())
	.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD)
		.nOut(parameters.getOutputSize()).weightInit(WeightInit.XAVIER).activation("softmax").build())
	.backprop(true).pretrain(false);

new ConvolutionLayerSetup(builder, parameters.getRows(), parameters.getColumns(), parameters.getChannels());

return builder.build();
   }
 
开发者ID:amrabed,项目名称:DL4J,代码行数:21,代码来源:ConvolutionalNetModel.java

示例8: net

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
private static MultiLayerConfiguration net(int nIn, int nOut) {
    return new NeuralNetConfiguration.Builder()
            .seed(42)
            .iterations(1)
            .activation(Activation.RELU)
            .weightInit(WeightInit.XAVIER)
            .learningRate(0.1)
            .regularization(true).l2(1e-4)
            .list(
                    new DenseLayer.Builder().nIn(nIn).nOut(3).build(),
                    new DenseLayer.Builder().nIn(3).nOut(3).build(),
                    new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD)
                            .activation(Activation.SOFTMAX)
                            .nIn(3)
                            .nOut(nOut)
                            .build()
            )
            .build();
}
 
开发者ID:wmeddie,项目名称:dl4j-trainer-archetype,代码行数:20,代码来源:Train.java

示例9: getConfiguration

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
private static MultiLayerConfiguration getConfiguration(DataFrame dataset) {

        MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
                .seed(seed)
                .constrainGradientToUnitNorm(true)
                .optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT)
                .list(4)
                .layer(0, new RBM.Builder(RBM.HiddenUnit.BINARY, RBM.VisibleUnit.BINARY)
                        .weightInit(WeightInit.XAVIER)
                        .nIn(rows * columns).nOut(600).build())
                .layer(1, new RBM.Builder(RBM.HiddenUnit.BINARY, RBM.VisibleUnit.BINARY)
                        .weightInit(WeightInit.XAVIER)
                        .nIn(600).nOut(250).build())
                .layer(2, new RBM.Builder(RBM.HiddenUnit.BINARY, RBM.VisibleUnit.BINARY)
                        .weightInit(WeightInit.XAVIER)
                        .nIn(250).nOut(200).build())
                .layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.RMSE_XENT)
                        .weightInit(WeightInit.XAVIER)
                        .activation("softmax")
                        .nIn(200).nOut(AUTOMATIC).build())
                .pretrain(true).backprop(false)
                .build();

        return conf;
    }
 
开发者ID:javadba,项目名称:dl4j-spark-ml-examples,代码行数:26,代码来源:JavaLfwClassification.java

示例10: testLayerName

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
@Test
public void testLayerName() {

    String name1 = "genisys";
    String name2 = "bill";

    MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
                    .layer(0, new DenseLayer.Builder().nIn(2).nOut(2).name(name1).build())
                    .layer(1, new DenseLayer.Builder().nIn(2).nOut(2).name(name2).build()).build();
    MultiLayerNetwork net = new MultiLayerNetwork(conf);
    net.init();

    assertEquals(name1, conf.getConf(0).getLayer().getLayerName());
    assertEquals(name2, conf.getConf(1).getLayer().getLayerName());

}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:17,代码来源:LayerConfigTest.java

示例11: testUpdaterAdamParamsLayerwiseOverride

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
@Test
public void testUpdaterAdamParamsLayerwiseOverride() {
    MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
            .updater(new Adam(1.0, 0.5, 0.5, 1e-8))
            .list()
            .layer(0, new DenseLayer.Builder().nIn(2).nOut(2).build())
                    .layer(1, new DenseLayer.Builder().nIn(2).nOut(2).updater(new Adam(1.0, 0.6, 0.7, 1e-8)).build())
                    .build();
    MultiLayerNetwork net = new MultiLayerNetwork(conf);
    net.init();

    assertEquals(0.5, ((Adam) ((BaseLayer) conf.getConf(0).getLayer()).getIUpdater()).getBeta1(), 0.0);
    assertEquals(0.6, ((Adam) ((BaseLayer) conf.getConf(1).getLayer()).getIUpdater()).getBeta1(), 0.0);
    assertEquals(0.5, ((Adam) ((BaseLayer) conf.getConf(0).getLayer()).getIUpdater()).getBeta2(), 0.0);
    assertEquals(0.7, ((Adam) ((BaseLayer) conf.getConf(1).getLayer()).getIUpdater()).getBeta2(), 0.0);
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:17,代码来源:LayerConfigTest.java

示例12: getNetwork

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
private MultiLayerNetwork getNetwork() {
    int nIn = 5;
    int nOut = 6;

    MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345).l1(0.01).l2(0.01)
            .updater(new Sgd(0.1)).activation(Activation.TANH).weightInit(WeightInit.XAVIER).list()
            .layer(0, new DenseLayer.Builder().nIn(nIn).nOut(20).build())
            .layer(1, new DenseLayer.Builder().nIn(20).nOut(30).build()).layer(2, new OutputLayer.Builder()
                    .lossFunction(LossFunctions.LossFunction.MSE).nIn(30).nOut(nOut).build())
            .build();

    MultiLayerNetwork net = new MultiLayerNetwork(conf);
    net.init();

    return net;
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:17,代码来源:ModelGuesserTest.java

示例13: testSeparableConv2D

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
@Test
public void testSeparableConv2D() {

    MultiLayerConfiguration.Builder builder = new NeuralNetConfiguration.Builder().list()
            .layer( new SeparableConvolution2D.Builder(2, 2)
                    .depthMultiplier(2)
                    .padding(0, 0)
                    .stride(2, 2).nIn(1).nOut(3).build()) //(28-2+0)/2+1 = 14
            .layer( new SubsamplingLayer.Builder().kernelSize(2, 2).padding(1, 1).stride(2, 2).build()) //(14-2+2)/2+1 = 8 -> 8x8x3
            .layer(2, new OutputLayer.Builder().nOut(3).build())
            .setInputType(InputType.convolutional(28, 28, 1));

    MultiLayerConfiguration conf = builder.build();

    assertNotNull(conf.getInputPreProcess(2));
    assertTrue(conf.getInputPreProcess(2) instanceof CnnToFeedForwardPreProcessor);
    CnnToFeedForwardPreProcessor proc = (CnnToFeedForwardPreProcessor) conf.getInputPreProcess(2);
    assertEquals(8, proc.getInputHeight());
    assertEquals(8, proc.getInputWidth());
    assertEquals(3, proc.getNumChannels());

    assertEquals(8 * 8 * 3, ((FeedForwardLayer) conf.getConf(2).getLayer()).getNIn());
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:24,代码来源:ConvolutionLayerSetupTest.java

示例14: getDenseMLNConfig

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
private static MultiLayerNetwork getDenseMLNConfig(boolean backprop, boolean pretrain) {
    int numInputs = 4;
    int outputNum = 3;
    long seed = 6;

    MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(seed)
                    .updater(new Sgd(1e-3)).l1(0.3).l2(1e-3).list()
                    .layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(numInputs).nOut(3)
                                    .activation(Activation.TANH).weightInit(WeightInit.XAVIER).build())
                    .layer(1, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(3).nOut(2)
                                    .activation(Activation.TANH).weightInit(WeightInit.XAVIER).build())
                    .layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
                                    .weightInit(WeightInit.XAVIER).nIn(2).nOut(outputNum).build())
                    .backprop(backprop).pretrain(pretrain).build();

    MultiLayerNetwork model = new MultiLayerNetwork(conf);
    model.init();
    return model;

}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:21,代码来源:DenseTest.java

示例15: incompleteLRN

import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入依赖的package包/类
public MultiLayerConfiguration.Builder incompleteLRN() {
    MultiLayerConfiguration.Builder builder =
                    new NeuralNetConfiguration.Builder().seed(3)
                                    .optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT).list()
                                    .layer(0, new org.deeplearning4j.nn.conf.layers.ConvolutionLayer.Builder(
                                                    new int[] {5, 5}).nOut(6).build())
                                    .layer(1, new org.deeplearning4j.nn.conf.layers.SubsamplingLayer.Builder(
                                                    new int[] {2, 2}).build())
                                    .layer(2, new LocalResponseNormalization.Builder().build())
                                    .layer(3, new org.deeplearning4j.nn.conf.layers.ConvolutionLayer.Builder(
                                                    new int[] {5, 5}).nOut(6).build())
                                    .layer(4, new org.deeplearning4j.nn.conf.layers.SubsamplingLayer.Builder(
                                                    new int[] {2, 2}).build())
                                    .layer(5, new org.deeplearning4j.nn.conf.layers.OutputLayer.Builder(
                                                    LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD).nOut(2)
                                                                    .build());
    return builder;
}
 
开发者ID:deeplearning4j,项目名称:deeplearning4j,代码行数:19,代码来源:ConvolutionLayerSetupTest.java


注:本文中的org.deeplearning4j.nn.conf.MultiLayerConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。