private double[] Candidate_Cell_Gate_3_Forward(double[] x, double[] reset_Gate) { double[] y = new double[weight_3_Small_Candidate_Cell.GetLength(1)]; double[] z = Matrix_work.Vector_Multiplication_Adamar_Shur(reset_Gate, state_GRU); for (int i = 0; i < weight_3_Small_Candidate_Cell.GetLength(1); i++) { for (int j = 0; j < weight_3_Small_Candidate_Cell.GetLength(0); j++) { y[i] = y[i] + (x[i] * weight_3_Small_Candidate_Cell[j, i]) + (z[i] * matrix_GRU_3_Candidate_Cell[j, i]); } } for (int i = 0; i < x.Length; i++) { y[i] = y[i] + bias_3_Candidate_Cell[i]; } for (int i = 0; i < x.Length; i++) { y[i] = Activation_Func.Tanh(y[i]); } return(y); }
public override double[] Perzertron_forward(double[] x) { double[] y = new double[weight_1_Small_Update_Gate.GetLength(0)]; double[] y_Left = new double[weight_1_Small_Update_Gate.GetLength(0)]; double[] y_Right = new double[weight_1_Small_Update_Gate.GetLength(0)]; double[] one = new double[weight_1_Small_Update_Gate.GetLength(0)]; for (int i = 0; i < one.Length; i++) { one[i] = 1; } double[] update_Cell = Update_Gate_1_Forward(x); double[] reset_Cell = Reset_Gate_2_Forward(x); double[] candidate_Cell = Candidate_Cell_Gate_3_Forward(x, reset_Cell); y_Left = Matrix_work.Vector_Multiplication_Adamar_Shur(Matrix_work.Vector_Substraction(one, update_Cell), candidate_Cell); y_Right = Matrix_work.Vector_Multiplication_Adamar_Shur(update_Cell, state_GRU); y = Matrix_work.Vector_Sum(y_Left, y_Right); Set_state_GRU(y); return(y); }
public override double[] Perzertron_forward(double[] x) { double[] y = new double[weight_1_Small_Candidate_Cell.GetLength(0)]; double[] candidate_Cell = Candidate_Cell_State_1_Forward(x); double[] input_Cell = Input_Gate_2_Forward(x); double[] forget_Cell = Forget_Gate_3_Forward(x); double[] output_cell = Output_Gate_4_Forward(x); double[] cell = Matrix_work.Vector_Sum(Matrix_work.Vector_Multiplication_Adamar_Shur(forget_Cell, state_LSTM_Memory), Matrix_work.Vector_Multiplication_Adamar_Shur(input_Cell, candidate_Cell)); Set_state_LSTM_Memory(cell); y = Matrix_work.Vector_Multiplication_Adamar_Shur(output_cell, Activation_Cell_Tanh(cell)); Set_state_LSTM(y); return(y); }