private void RunModelLogic() { if (run && !m_EasyRapidlib.isModelEmpty) { // DTW if (learningType == EasyRapidlib.LearningType.DTW) { // We init the running serie if it is null if (m_RunningSerieDTW.ExampleSerie == null) { m_RunningSerieDTW = new RapidlibTrainingSerie(); } // We start adding examples to the running serie until the user stops AddExampleToSerie(ref m_RunningSerieDTW); } // Classification and Regression else { // Extract all the features from the input object double[] modelInputs = null; int sizeModelInput = 0; // Calculate size of the model input vector [I CAN MOVE THIS TO THE START OF THE PROGRAM] for (int i = 0; i < m_Features.Count; i++) { sizeModelInput += (m_LengthsFeatureVector[i] * inputs.Length); } modelInputs = new double[sizeModelInput]; if (modelInputs != null) { m_ExtractFeatures(ref modelInputs, inputs); } ////Debug.Log(input); ////Debug.Log(input.Length); //for (int i = 0; i < input.Length; i++) //{ // //Debug.Log(input[i]); //} ////Debug.Log(outputs); ////Debug.Log(outputs.Length); //for (int i = 0; i < outputs.Length; i++) //{ // //Debug.Log(outputs[i]); //} // Get the predictions based on the features we input outputs = m_EasyRapidlib.Run(modelInputs, outputs.Length); } } }
/// <summary> /// Adds a single example to a serie /// </summary> /// <param name="serieToReceiveExample"></param> public void AddExampleToSerie(ref RapidlibTrainingSerie serieToReceiveExample) { // Calculate size of the new example input vector [I CAN MOVE THIS TO THE START OF THE PROGRAM] int sizeNewExampleInput = 0; for (int i = 0; i < m_Features.Count; i++) { sizeNewExampleInput += (m_LengthsFeatureVector[i] * inputs.Length); } double[] singleInputExampleInSerie = new double[sizeNewExampleInput]; m_ExtractFeatures(ref singleInputExampleInSerie, inputs); // Add a single example to the training serie dtw that we will push later on to easyRapidlib serieToReceiveExample.AddTrainingExample(singleInputExampleInSerie, OutputDTW.ToString()); }