public R2Tensor ForwardPropagation(R2Tensor Input, bool norm = true) { R2Tensor Hidden = Tanh(R2Tensor.Add(R2Tensor.MatMul(ih_weight, Input), ih_bias)); if (!norm) { return(Hidden); } R2Tensor Output = R2Tensor.Add(R2Tensor.MatMul(ho_weight, Hidden), ho_bias); return(Sign(Output)); }
public R2Tensor ForwardPropagation(R2Tensor Input, bool norm = true) { R2Tensor Hidden = Tanh(R2Tensor.Add(R2Tensor.MatMul(ih_weight, Input), ih_bias)); if (!norm) { return(Hidden); } R2Tensor Output = R2Tensor.Add(R2Tensor.MatMul(ho_weight, Hidden), ho_bias); switch (outtype) { case "Basisdirection": return(Tanh(Output)); case "Direction": int maxind = Max(Output); float[] tensor_out = new float[9]; for (int i = 0; i < 9; i++) { if (i == maxind) { tensor_out[i] = 1; continue; } tensor_out[i] = 0; } return(R2Tensor.ToMatrix(tensor_out, "col")); case "Keystroke": return(Sign(Output)); case "Debug": return(Output); default: return(Output); } }