title: c++-default_random_engine creates all the time same series of numbers
body: <p>I am working with neural networks, and I want to create the weights randomly. SO if I create 30 Neural networks every single one of them ends up having the same weights(supposed to be random) so when i give them all the same input the output is the same, when it shouldn't. Any help?</p>
  
  <p>Here is the main function</p>
  
  <pre><code>int main(){
  std::vector&lt;Improved_NN&gt; v;
  std::random_device rd;
  std::default_random_engine generator(rd());
  std::uniform_real_distribution&lt;double&gt; distribution(-1.0,1.0);
  for(int i = 0; i &lt; 30; i++)
  {
      Improved_NN temp;
      temp.initialize_weights(generator, distribution);
      v.push_back(temp);
  }
  
  Board temp;
  
  for(int i = 0; i &lt; 30; i++)
  {
      std::cout &lt;&lt;"\n" &lt;&lt; v[i].executeFromExternal(temp);
  }
  </code></pre>
  
  <p>And the initialize_weights is here:</p>
  
  <pre><code> void Improved_NN::initialize_weights(std::default_random_engine gen,std::uniform_real_distribution&lt;double&gt; dist){
  int k,v = 0;
  for(k = 0;k&lt;NUM_HIDDEN_1;k++){
      for(v = 0 ; v &lt; NUM_INPUTS; v++){
          mlp_t.w_h1_i[k][v]=dist(gen);
          //std::cout&lt;&lt;mlp_t.w_h1_i[k][v]&lt;&lt;std::endl;
      }
  }
  for(k = 0;k&lt;NUM_HIDDEN_2;k++){
      for(v = 0 ; v &lt; NUM_HIDDEN_1; v++){
          mlp_t.w_h2_h1[k][v]=dist(gen);
          //std::cout&lt;&lt;mlp_t.w_h2_h1[k][v]&lt;&lt;std::endl;
      }
  }
  for(k = 0;k&lt;NUM_HIDDEN_3;k++){
      for(v = 0 ; v &lt; NUM_HIDDEN_2; v++){
          mlp_t.w_h3_h2[k][v]=dist(gen);
          //std::cout&lt;&lt;mlp_t.w_h3_h2[k][v]&lt;&lt;std::endl;
      }
  }
      for (int a = 0 ; a &lt; NUM_HIDDEN_3;a++){
          mlp_t.w_o_h[0][a] = dist(gen);
          //std::cout&lt;&lt;mlp_t.w_o_h[0][a]&lt;&lt;std::endl;
      }
  }
  </code></pre>
  
  <p>This is the output i get every time i execute.</p>
  
  <p>0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458
  0.521458</p>
  
  <p>Thank you very much.</p>