title: Exact repeatability of PyBrain experiments
body: <p>What parameters in pybrain should be set to ensure exact replication of results when using the neural network modules as shown in the code below?</p>
  
  <p>For each new run, the outputs differ although the random seed is set to the same value. The weights and biases are also the same for each run (due to <code>np.random.seed(0)</code>).</p>
  
  <p>The weights and biases can also be set using <code>net._setParameters()</code>, but the results are also different when following this approach.</p>
  
  <pre><code>#!/usr/bin/python
  #Python 2.7
  
  from __future__ import division
  import numpy as np
  from pybrain.structure import SigmoidLayer, LinearLayer, TanhLayer
  from pybrain.datasets import SupervisedDataSet 
  from pybrain.supervised.trainers import BackpropTrainer 
  from pybrain.tools.shortcuts import buildNetwork
  
  np.random.seed(0)
  net = buildNetwork(1,2,1,hiddenclass=SigmoidLayer,outclass=LinearLayer,bias=True)
  
  N = 10
  t = np.arange(0,N,1)/N
  x = np.cos(2*np.pi*0.1*t)
  y = np.cos(2*np.pi*0.1*t)
  
  ds = SupervisedDataSet(1, 1)
  for c in range(N):
   ds.addSample(x[c], y[c])
  
  #net._setParameters(np.random.normal(0,1,(len(net.params))))
  #net._setParameters(np.array([1.0]*len(net.params)))
  trainer = BackpropTrainer(net, ds)
  print 'NN parameters after setup:'
  print net.params
  
  for c in range(2):
   e1 = trainer.train()
   print 'Epoch %d Error: %f'%(c,e1)
  print 'NN parameters after training:'
  print net.params
  
  p=np.zeros(N)
  for c in range(N):
   p[c] = net.activate([x[c]])
  
  err = np.sum((y-p)**2)/N
  print 'Prediction error = %2.4f'%err
  </code></pre>
  
  <p>The output of the code for two consecutive runs:</p>
  
  <p>Run 1:</p>
  
  <pre><code>NN parameters after setup:
  [ 1.76405235  0.40015721  0.97873798  2.2408932   1.86755799 -0.97727788
    0.95008842]
  Epoch 0 Error: 0.258780
  Epoch 1 Error: 0.149163
  NN parameters after training:
  [ 1.63888191  0.40916677  0.97224621  2.24929727  1.8615028  -1.09298541
    0.83265293]
  Prediction error = 0.2179
  </code></pre>
  
  <p>Run 2:</p>
  
  <pre><code>NN parameters after setup:
  [ 1.76405235  0.40015721  0.97873798  2.2408932   1.86755799 -0.97727788
    0.95008842]
  Epoch 0 Error: 0.258757
  Epoch 1 Error: 0.148765
  NN parameters after training:
  [ 1.6384432   0.40916969  0.97225458  2.24931834  1.86149186 -1.09343599
    0.83221073]
  Prediction error = 0.2167
  </code></pre>
  
  <p>Clearly, the NN parameters before training are identical for both cases. After training, the NN parameters differ (and hence the predicted results and errors during training).</p>