Skip to content

Instantly share code, notes, and snippets.

@cawfree
Created February 25, 2017 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cawfree/2393c90223ab085fe92860759f23b88e to your computer and use it in GitHub Desktop.
Save cawfree/2393c90223ab085fe92860759f23b88e to your computer and use it in GitHub Desktop.
02-25 21:14:08.391 16707 16707 E AndroidRuntime: Caused by: org.deeplearning4j.exception.DL4JInvalidConfigException: ConvolutionLayer (index=2, name=(name not set)) nIn=0, nOut=50; nIn and nOut must be > 0
/* Neural Dependencies. */
private static final int IMAGE_WIDTH = 64;
private static final int IMAGE_HEIGHT = 80;
private static final int SEED = 123;
private static final int ITERATIONS = 1;
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
.seed(SEED)
.iterations(ITERATIONS) // Training iterations as above
.regularization(true).l2(0.0005)
/*
Uncomment the following for learning decay and bias
*/
.learningRate(.01)//.biasLearningRate(0.02)
//.learningRateDecayPolicy(LearningRatePolicy.Inverse).lrPolicyDecayRate(0.001).lrPolicyPower(0.75)
.weightInit(WeightInit.XAVIER)
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
.updater(Updater.NESTEROVS).momentum(0.9)
.list()
.layer(0, new ConvolutionLayer.Builder(5, 5)
//nIn and nOut specify depth. nIn here is the nChannels and nOut is the number of filters to be applied
.nIn(IMAGE_WIDTH * IMAGE_HEIGHT)
.stride(1, 1)
.nOut(20)
.activation(Activation.IDENTITY)
.build())
.layer(1, new SubsamplingLayer.Builder(SubsamplingLayer.PoolingType.MAX)
.kernelSize(2,2)
.stride(2,2)
.build())
.layer(2, new ConvolutionLayer.Builder(5, 5)
//Note that nIn need not be specified in later layers
.stride(1, 1)
.nOut(50)
.activation(Activation.IDENTITY)
.build())
.layer(3, new SubsamplingLayer.Builder(SubsamplingLayer.PoolingType.MAX)
.kernelSize(2,2)
.stride(2,2)
.build())
.layer(4, new DenseLayer.Builder().activation(Activation.RELU)
.nOut(500).build())
.layer(5, new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD)
.nOut(CharacterizationUtils.CARD_NUM_SIGNALS)
.activation(Activation.SOFTMAX)
.build())
.backprop(true).pretrain(false).build();
MultiLayerNetwork myNetwork = new MultiLayerNetwork(conf);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment