{"action":"closed","issue":{"url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/issues/1358","repository_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j","labels_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/issues/1358/labels{/name}","comments_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/issues/1358/comments","events_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/issues/1358/events","html_url":"https://github.com/deeplearning4j/deeplearning4j/issues/1358","id":145644734,"number":1358,"title":"SubsamplingLayer Null Pointer Exception on toFlattened (CpuNDArrayFactory)","user":{"login":"ShakMR","id":3437307,"avatar_url":"https://avatars.githubusercontent.com/u/3437307?v=3","gravatar_id":"","url":"https://api.github.com/users/ShakMR","html_url":"https://github.com/ShakMR","followers_url":"https://api.github.com/users/ShakMR/followers","following_url":"https://api.github.com/users/ShakMR/following{/other_user}","gists_url":"https://api.github.com/users/ShakMR/gists{/gist_id}","starred_url":"https://api.github.com/users/ShakMR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ShakMR/subscriptions","organizations_url":"https://api.github.com/users/ShakMR/orgs","repos_url":"https://api.github.com/users/ShakMR/repos","events_url":"https://api.github.com/users/ShakMR/events{/privacy}","received_events_url":"https://api.github.com/users/ShakMR/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"AlexDBlack","id":2360237,"avatar_url":"https://avatars.githubusercontent.com/u/2360237?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexDBlack","html_url":"https://github.com/AlexDBlack","followers_url":"https://api.github.com/users/AlexDBlack/followers","following_url":"https://api.github.com/users/AlexDBlack/following{/other_user}","gists_url":"https://api.github.com/users/AlexDBlack/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexDBlack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexDBlack/subscriptions","organizations_url":"https://api.github.com/users/AlexDBlack/orgs","repos_url":"https://api.github.com/users/AlexDBlack/repos","events_url":"https://api.github.com/users/AlexDBlack/events{/privacy}","received_events_url":"https://api.github.com/users/AlexDBlack/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2016-04-04T10:32:10Z","updated_at":"2016-04-06T19:34:43Z","closed_at":"2016-04-06T19:34:43Z","body":"When using the master (version 0.4-rc3.9) branch of DeepLearning4j and I'm getting some Null Pointer.\r\nThe network definition is this (copied from the repository [LenetMnistExample](https://github.com/deeplearning4j/dl4j-0.4-examples/blob/master/src/main/java/org/deeplearning4j/examples/convolution/LenetMnistExample.java)):\r\n\r\n        builder = new NeuralNetConfiguration.Builder()\r\n                .seed(seed)\r\n                .iterations(iterations)\r\n                .regularization(true).l2(0.0005)\r\n                .learningRate(0.01)\r\n                .weightInit(WeightInit.XAVIER)\r\n                .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)\r\n                .updater(Updater.NESTEROVS).momentum(0.9)\r\n                .list(4)\r\n                .layer(0, new ConvolutionLayer.Builder(5, 5)\r\n                        .nIn(nChannels)\r\n                        .stride(1, 1)\r\n                        .nOut(20).dropOut(0.5)\r\n                        .activation(\"relu\")\r\n                        .build())\r\n                .layer(1, new SubsamplingLayer.Builder(SubsamplingLayer.PoolingType.MAX)\r\n                        .kernelSize(2,2)\r\n                        .stride(2,2)\r\n                        .build())\r\n                .layer(2, new DenseLayer.Builder().activation(\"relu\")\r\n                        .nOut(500).build())\r\n                .layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD)\r\n                        .nOut(outputNum)\r\n                        .activation(\"softmax\")\r\n                        .build())\r\n                .backprop(true).pretrain(false);\r\n\r\nThe exception showned is this:\r\n\r\n    Exception in thread \"main\" java.lang.NullPointerException\r\n    \tat org.nd4j.linalg.cpu.nativecpu.CpuNDArrayFactory.toFlattened(CpuNDArrayFactory.java:489)\r\n    \tat org.nd4j.linalg.factory.Nd4j.toFlattened(Nd4j.java:1575)\r\n    \tat org.deeplearning4j.nn.multilayer.MultiLayerNetwork.params(MultiLayerNetwork.java:861)\r\n    \tat org.deeplearning4j.spark.impl.multilayer.SparkDl4jMultiLayer.runIteration(SparkDl4jMultiLayer.java:374)\r\n    \tat org.deeplearning4j.spark.impl.multilayer.SparkDl4jMultiLayer.fitDataSet(SparkDl4jMultiLayer.java:344)\r\n    \tat org.deeplearning4j.ml.JavaMNistClass.main(JavaMNistClass.java:285)\r\n    \tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n    \tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n    \tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n    \tat java.lang.reflect.Method.invoke(Method.java:498)\r\n    \tat org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:672)\r\n    \tat org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:180)\r\n    \tat org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:205)\r\n    \tat org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:120)\r\n    \tat org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)\r\n\r\nI've debbuged this using an IDE and find that the *NullPointerException* is thrown due to a null element in a *Collection<INDArray>* in:\r\n\r\nCpuNDArrayFactory.java:489\r\n\r\nResearching for the origin of this null element, I've found that it is originated when (in *org.deeplearning4j.nn.multilayer.MultiLayerNetwork.params()* around line 858) the layer number 1 (which correspons to the *SubsamplingLayer*) didn't have any parameter.\r\n\r\nIndeed, you cannot set any parameter to the *SubsamplingLayer*, taking in account that this parameters are the *nIn* and *nOut* functions of the other layers (guessed by debugging).\r\n"}}