public override String ToString() { StringBuilder sb = new StringBuilder(); sb.Append($"{DocumentIdentifier},"); sb.Append($"{FileOrder},"); sb.Append($"{X},"); sb.Append($"{Y},"); sb.Append($"{Width},"); sb.Append($"{Height},"); sb.Append($"{MarkupType},"); sb.Append($"{(FillA == null ? "null" : FillA.ToString())},"); sb.Append($"{(FillR == null ? "null" : FillR.ToString())},"); sb.Append($"{(FillG == null ? "null" : FillG.ToString())},"); sb.Append($"{(FillB == null ? "null" : FillB.ToString())},"); sb.Append($"{(BorderSize == null ? "null" : BorderSize.ToString())},"); sb.Append($"{(BorderA == null ? "null" : BorderA.ToString())},"); sb.Append($"{(BorderR == null ? "null" : BorderR.ToString())},"); sb.Append($"{(BorderG == null ? "null" : BorderG.ToString())},"); sb.Append($"{(BorderB == null ? "null" : BorderB.ToString())},"); sb.Append($"{(BorderStyle == null ? "null" : BorderStyle.ToString())},"); sb.Append($"{FontName},"); sb.Append($"{(FontA == null ? "null" : FontA.ToString())},"); sb.Append($"{(FontR == null ? "null" : FontR.ToString())},"); sb.Append($"{(FontG == null ? "null" : FontG.ToString())},"); sb.Append($"{(FontB == null ? "null" : FontB.ToString())},"); sb.Append($"{(FontSize == null ? "null" : FontSize.ToString())},"); sb.Append($"{(FontStyle == null ? "null" : FontStyle.ToString())},"); sb.Append($"{Text},"); sb.Append($"{ZOrder},"); String drawCrossLinesValue = DrawCrossLines ? "1" : "0"; sb.Append($"{drawCrossLinesValue},"); sb.Append($"{MarkupSubType},"); sb.Append($"{(Xd == null ? "null" : Xd.ToString())},"); sb.Append($"{(Yd == null ? "null" : Yd.ToString())},"); sb.Append($"{(WidthD == null ? "null" : WidthD.ToString())},"); sb.Append($"{(HeightD == null ? "null" : HeightD.ToString())}"); String retVal = sb.ToString(); return(retVal); }
public int entrenar() { float sumaEl; float sumaEp; int m = X.GetLength(1); //entradas int n = Yd.GetLength(1); //salidas int patrones = Yd.GetLength(0); //patrones float[] El = new float[n]; float[] Y = new float[n]; float[] Ep = new float[patrones]; float erms; float[] soma = new float[n]; float[] U = new float[n]; float[,] W = new float[m, n]; var random = new Random(-1); List <float> listaErrores = new List <float>(); List <float> listaErrorMaestro = new List <float>(); float[,] listaPeso = new float[m, n]; float[] listaumbrales = new float[n]; for (int i = 0; i < n; i++) { U[i] = (float)random.NextDouble(); Console.WriteLine(string.Format("U[{0}] = {1} %n", i, U[i])); Console.WriteLine(""); for (int j = 0; j < m; j++) { W[j, i] = (float)random.NextDouble(); } } Console.WriteLine("Umbrales"); for (int i = 0; i < n; i++) { Console.WriteLine(string.Format("U[{0}] = {1} \t", i, U[i])); } Console.WriteLine("Pesos"); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { Console.WriteLine(string.Format("W[{0},{1}] = {2} \t", j, i, W[j, i])); } Console.WriteLine(""); } for (int e = 1; e <= NumeroIteraciones; e++) { sumaEl = 0; sumaEp = 0; erms = 0; for (int p = 0; p < patrones; p++) { for (int i = 0; i < n; i++) { soma[i] = 0; El[i] = 0; for (int j = 0; j < m; j++) { soma[i] = soma[i] + X[p, j] * W[j, i]; }//ciclo de salidas soma[i] = soma[i] + U[i]; Y[i] = activacion(soma[i]); El[i] = Yd[p, i] - Y[i]; Console.WriteLine(string.Format("el[{0}]={1} - {2} ", i, Yd[p, i], Y[i])); Console.WriteLine(string.Format("el[{0}]:{1} ", i, El[i])); sumaEl = sumaEl + Math.Abs(El[i]); }//ciclo entradas //actualizacion de pesos y umbrales for (int i = 0; i < n; i++) { U[i] = U[i] + RataAprendizaje * El[i]; listaumbrales[i] = U[i]; for (int j = 0; j < m; j++) { W[j, i] = W[j, i] + RataAprendizaje * El[i] * X[p, j]; listaPeso[j, i] = W[j, i]; } } formEntrenamiento.graficarPesosUmbrales(listaPeso, listaumbrales); Console.WriteLine("Suma El " + sumaEl); Ep[p] = sumaEl / patrones; sumaEp = sumaEp + Ep[p]; Console.WriteLine(string.Format("Ep[{0}]: {1} ", p, Ep[p])); }//ciclo recorrido de patrones Console.WriteLine("Suma Ep " + sumaEp); erms = sumaEp / patrones; Console.WriteLine("iteraciones " + e); Console.WriteLine("ERMS " + erms); listaErrores.Add(erms); listaErrorMaestro.Add(ErrorMaximo); Thread.Sleep(1000); formEntrenamiento.graficarErrorIteracion(listaErrores, listaErrorMaestro); formEntrenamiento.mostrarErrrorIteracion(e, erms); formEntrenamiento.actualizarProgreso(e); if (erms <= ErrorMaximo) { formEntrenamiento.actualizarProgreso(NumeroIteraciones); formEntrenamiento.finalizarEntrenamiento(true); guardar(); Console.WriteLine("iteraciones " + e); return(1); } //Console.WriteLine(" ERROR ERMS "+sumaEp+" "+e+" iteraciones"); Console.WriteLine("\n"); } formEntrenamiento.finalizarEntrenamiento(false); return(0); }