public Layer(int inputs_size, int output_size, Squash_func.SQUASH_FUNC func, uint index = 0, double learn_rate = 0.01) { out_size = output_size; input_size = inputs_size; neurons = new Neuron[out_size]; for (int i = 0; i < neurons.Length; i++) { neurons[i] = new Neuron(func, inputs_size, learn_rate); } inputs = DenseVector.Build.Dense(input_size, 0); outputs = DenseVector.Build.Dense(out_size, 0); layer_index = index; }
public Neuron(Squash_func.SQUASH_FUNC func, int input_size, double learn_rate) { //Init the squash function squash_func = new Func <double, double>(x => Squash_func.squash(func, x)); //Init the derivative of the squash function squash_func_derivate = new Func <double, double>(x => Squash_func.derivative_squash(func, x)); Random random = new Random(); //Initialize the weights of the neuron to random value between 0 and 1 weigths = DenseVector.Build.Dense(input_size).Map(x => random.NextDouble()); //Initilize the bias to a random value between 0 and 1 bias = random.NextDouble(); forward_propagation_done = false; learning_rate = learn_rate; }
public void add_layer(int in_size, int out_size, Squash_func.SQUASH_FUNC func = Squash_func.SQUASH_FUNC.TANH) { neural_net_layers_list.Add(new Layer(in_size, out_size, func, (uint)neural_net_layers_list.Count, learn_rate: this.learn_rate)); }