# Simple CNN predicts NaNs

**URL:** <https://community.konduit.ai/t/simple-cnn-predicts-nans/964>\
**Category:** DL4J\
**Created:** [November 2, 2020, 9:27am UTC](https://community.konduit.ai/t/simple-cnn-predicts-nans/964 "2020-11-02T09:27:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zsvizi](https://avatars.discourse-cdn.com/v4/letter/z/a9adbd/32.png) [@zsvizi](https://community.konduit.ai/u/zsvizi)\
**Post date:** [November 2, 2020, 9:27am UTC](https://community.konduit.ai/t/simple-cnn-predicts-nans/964/1 "2020-11-02T09:27:39Z")

</div>

Hi All,  
I am newbie in DL4J. I tried to implement a simple CNN like this:

```auto
val conf = new NeuralNetConfiguration.Builder()
    .seed(seed)
    .updater(Updater.NESTEROVS)
    .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
    .weightInit(WeightInit.XAVIER)
    .list
    .layer(0, new ConvolutionLayer.Builder()
      .name("c1")
      .kernelSize(5, numFeatures)
      .convolutionMode(ConvolutionMode.Truncate)
      .activation(Activation.RELU)
      .nIn(1)
      .nOut(32)
      .build)
    .layer(1, new OutputLayer.Builder(LossFunctions.LossFunction.MSE)
      .nOut(nOut)
      .dropOut(0.5)
      .activation(Activation.IDENTITY)
      .build)
    .setInputType(InputType.convolutional(windowSize, numFeatures, 1))
    .build

```

My first minibatch has size `[batchSize, 1, windowSize, numFeatures]` , so compatible with the CNN. The problem now, that I got `NaN` values from inference, thus the network does not learn… I want to use this network for time series prediction (trying this for first, then later going to RNN).  
Do you have any idea, what causes the problem? The network gives sensible values after init, but after first iteration only `NaN` values are outputed.  
In the dependencies, I have 0.9.1 version  
Thank you for your help in advance!

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [November 2, 2020, 10:32am UTC](https://community.konduit.ai/t/simple-cnn-predicts-nans/964/2 "2020-11-02T10:32:03Z")

</div>

> [@zsvizi](#):
>
> ave 0.9.1 version  
> Thank you for your help in advance

@zsvizi first of all, make sure you update your version to 1.0.0-beta7.  
That’s what the current examples: [GitHub - deeplearning4j/deeplearning4j-examples: Deeplearning4j Examples (DL4J, DL4J Spark, DataVec)](https://github.com/eclipse/deeplearning4j-examples) is

Also, make sure to read this first: [https://deeplearning4j.konduit.ai/tuning-and-training/troubleshooting-training](https://deeplearning4j.konduit.ai/tuning-and-training/troubleshooting-training)

After you do that, let us know what you find.

---

<div class="post-metadata">

**Author:** ![zsvizi](https://avatars.discourse-cdn.com/v4/letter/z/a9adbd/32.png) [@zsvizi](https://community.konduit.ai/u/zsvizi)\
**Post date:** [November 2, 2020, 10:36am UTC](https://community.konduit.ai/t/simple-cnn-predicts-nans/964/3 "2020-11-02T10:36:10Z")

</div>

The problem is, that the project I am working on is maintained by the DevOps team of the company I am working for… and you know, upgrading a dependency is far from trivial. Considering these constrains, can you suggest some approach to troubleshoot?

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [November 2, 2020, 11:10am UTC](https://community.konduit.ai/t/simple-cnn-predicts-nans/964/4 "2020-11-02T11:10:42Z")

</div>

@zsvizi we can try but we have our own constraints as well 🙂 that tuning guide should still be relevant for you. If you need something more for support, please feel free to DM me and we’ll see what we can do for you.
