Advertisement
Lena-hyena

NN

Oct 20th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Random;
  3. import java.util.concurrent.ThreadLocalRandom;
  4.  
  5. public class nwrk {
  6. private double[][] output;
  7. private double[][][] weights;
  8. private double[][] bias;
  9.  
  10. private double[][] errors;
  11. private double[][] derivatives_out;
  12.  
  13. public int[] layer_size;
  14. public int input_size;
  15. public int output_size;
  16. public int nwrk_size;
  17.  
  18. public nwrk(int... layer_size) {
  19. this.layer_size = layer_size;
  20. this.input_size = layer_size[0];
  21. this.nwrk_size = layer_size.length;
  22. this.output_size = layer_size[nwrk_size-1];
  23.  
  24. this.output = new double[nwrk_size][];
  25. this.weights = new double[nwrk_size][][];
  26. this.bias = new double[nwrk_size][];
  27.  
  28. this.errors = new double[nwrk_size][];
  29. this.derivatives_out = new double[nwrk_size][];
  30.  
  31. for(int i=0; i< nwrk_size; i++){
  32. this.output[i] = new double[layer_size[i]];
  33. this.errors[i] = new double[layer_size[i]];
  34. this.derivatives_out[i] = new double[layer_size[i]];
  35.  
  36. this.bias[i] = rand_array(-0.5, 0.7, layer_size[i]);
  37.  
  38. // weights??
  39. }
  40. }
  41.  
  42. public static double[] rand_array(double min, double max, int size){
  43. double[] randomArray = new double[size];
  44. Random randNumGenerator = new Random();
  45. for (int i = 0; i < size; i++) {
  46. randomArray[i] = ThreadLocalRandom.current().nextDouble(min, max);;
  47. }
  48. return randomArray;
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement