title: PyBrain: overflow encountered in square, invalid value encountered in multiply
body: <p>I create a neural network like this:</p>
  
  <pre><code>n = FeedForwardNetwork()
  
  inLayer = LinearLayer(43)
  bias = BiasUnit()
  hiddenLayer = SigmoidLayer(100)
  outLayer = LinearLayer(1)
  
  n.addInputModule(inLayer)
  n.addModule(bias)
  n.addModule(hiddenLayer)
  n.addOutputModule(outLayer)
  
  in_to_hidden = FullConnection(inLayer, hiddenLayer)
  bias_to_hidden = FullConnection(bias, hiddenLayer)
  hidden_to_out = FullConnection(hiddenLayer, outLayer)
  
  n.addConnection(in_to_hidden)
  n.addConnection(bias_to_hidden)
  n.addConnection(hidden_to_out)
  
  n.sortModules()
  </code></pre>
  
  <p>I train it the following way (I'm simplifying, it's being trained in multiple iterations):</p>
  
  <pre><code>self.trainer = BackpropTrainer(self.neural_net, learningrate=0.8)
  (...)
  ds = SupervisedDataSet(self.net_input_size, 1)
  ds.addSample([...], np.float64(learned_value))
  (...)
  self.trainer.trainOnDataset(ds)
  </code></pre>
  
  <p>Sometimes I get the following warnings:</p>
  
  <blockquote>
    <p>(...)/lib/python3.5/site-packages/PyBrain-0.3.1-py3.5.egg/pybrain/supervised/trainers/backprop.py:99: RuntimeWarning: overflow encountered in square
      error += 0.5 * sum(outerr ** 2)</p>
    
    <p>(...)/lib/python3.5/site-packages/PyBrain-0.3.1-py3.5.egg/pybrain/structure/modules/sigmoidlayer.py:14: RuntimeWarning: invalid value encountered in multiply
      inerr[:] = outbuf * (1 - outbuf) * outerr</p>
  </blockquote>
  
  <p>And then when I check the saved net file I see that <em>all</em> weights are <code>nan</code>:</p>
  
  <pre><code>(...)
  &lt;FullConnection class="pybrain.structure.connections.full.FullConnection" name="FullConnection-8"&gt;
      &lt;inmod val="BiasUnit-5"/&gt;
      &lt;outmod val="SigmoidLayer-11"/&gt;
      &lt;Parameters&gt;[nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan]&lt;/Parameters&gt;
  &lt;/FullConnection&gt;
  (...)
  </code></pre>