Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Random;
- import java.util.concurrent.ThreadLocalRandom;
- public class nwrk {
- private double[][] output;
- private double[][][] weights;
- private double[][] bias;
- private double[][] errors;
- private double[][] derivatives_out;
- public int[] layer_size;
- public int input_size;
- public int output_size;
- public int nwrk_size;
- public nwrk(int... layer_size) {
- this.layer_size = layer_size;
- this.input_size = layer_size[0];
- this.nwrk_size = layer_size.length;
- this.output_size = layer_size[nwrk_size-1];
- this.output = new double[nwrk_size][];
- this.weights = new double[nwrk_size][][];
- this.bias = new double[nwrk_size][];
- this.errors = new double[nwrk_size][];
- this.derivatives_out = new double[nwrk_size][];
- for(int i=0; i< nwrk_size; i++){
- this.output[i] = new double[layer_size[i]];
- this.errors[i] = new double[layer_size[i]];
- this.derivatives_out[i] = new double[layer_size[i]];
- this.bias[i] = rand_array(-0.5, 0.7, layer_size[i]);
- // weights??
- }
- }
- public static double[] rand_array(double min, double max, int size){
- double[] randomArray = new double[size];
- Random randNumGenerator = new Random();
- for (int i = 0; i < size; i++) {
- randomArray[i] = ThreadLocalRandom.current().nextDouble(min, max);;
- }
- return randomArray;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement