public void Make2DMatrixTest() { int vSize = 15; Vector <float> V = Vector <float> .Build.Random(vSize); int iter = 100000; Matrix <float> M; var watch = System.Diagnostics.Stopwatch.StartNew(); for (int i = 0; i < iter; i++) { M = UMatrix.Make2DMatrix(V, 5, 3); } watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; Debug.Log("Time Col mode: " + elapsedMs); watch = System.Diagnostics.Stopwatch.StartNew(); for (int i = 0; i < iter; i++) { M = UMatrix.Make2DMatrix(V, 5, 3, false); } watch.Stop(); elapsedMs = watch.ElapsedMilliseconds; Debug.Log("Time Row mode: " + elapsedMs); M = UMatrix.Make2DMatrix(V, 5, 3); Debug.Log(V); Debug.Log(M); }
/*RaycastHit hit; * Ray downRay;*/ void BuildCustomWeights(Vector <float> individual) { tmpBuildCustomWeights.Clear(); for (int i = 0; i < shapes.Count - 1; i++) { if (i == 0) { tmpBuildCustomWeights.Add(UMatrix.Make2DMatrix(individual.SubVector(0, (shapes[i] + 1) * shapes[i + 1]), shapes[i + 1], shapes[i] + 1)); } else { tmpBuildCustomWeights.Add(UMatrix.Make2DMatrix(individual.SubVector((shapes[i - 1] + 1) * shapes[i], (shapes[i] + 1) * shapes[i + 1]), shapes[i + 1], shapes[i] + 1)); } } }
void BuildCustomWeights(List <Matrix <float> > newWeights, List <int> shapes, Vector <float> individual) { int bias = 1; for (int i = 0; i < shapes.Count - 1; i++) { if (i == shapes.Count - 2) { bias = 0; } if (i == 0) { // Debug.Log(newWeights[i]); // Debug.Log(individual.SubVector(0, (shapes[i] + 1) * (shapes[i + 1] + bias))); UMatrix.Make2DMatrix(newWeights[i], individual.SubVector(0, (shapes[i] + 1) * (shapes[i + 1] + bias)), (shapes[i + 1] + bias), shapes[i] + 1); } else { UMatrix.Make2DMatrix(newWeights[i], individual.SubVector((shapes[i - 1] + 1) * shapes[i], (shapes[i] + 1) * (shapes[i + 1] + bias)), (shapes[i + 1] + bias), shapes[i] + 1); } } }