Esempio n. 1
0
        private void Initialize()
        {
            // Make sure inputs array is not null (to avoid null references when opening for the first time the project)
            if (inputs == null)
            {
                inputs = new Transform[0];
            }

            // Set size of outputs array to 1
            outputs = new double[1];

            // Storing the this frame as the last frame to properly calculate velocity every frame
            m_LastFramePosition = this.transform.position;

            // Initialize array of distance of all inputs to first one based on number of inputs
            if (inputs.Length > 0)
            {
                // We will need to calculate the distance from everything to the first one
                m_DistancesToFirstInput = new float[inputs.Length - 1];
            }

            // Initialise instance of easy rapidlib
            if (m_EasyRapidlib == null)
            {
                m_EasyRapidlib = new EasyRapidlib(learningType);
            }
        }
Esempio n. 2
0
 public List <RapidlibTrainingSerie> GetTrainingExamplesSeries()
 {
     if (m_EasyRapidlib == null)
     {
         m_EasyRapidlib = new EasyRapidlib(learningType);
     }
     if (m_EasyRapidlib.TrainingExamplesSeries == null)
     {
         m_EasyRapidlib.TrainingExamplesSeries = new List <RapidlibTrainingSerie>();
     }
     return(m_EasyRapidlib.TrainingExamplesSeries);
 }
Esempio n. 3
0
        // Called when the script is loaded or a value is changed in the inspector (Called in the editor only).
        private void OnValidate()
        {
            // Make sure easy rapidlib instance exists
            if (m_EasyRapidlib == null)
            {
                m_EasyRapidlib = new EasyRapidlib(learningType);
            }

            // Did the learning type change in the editor?
            if (learningType != m_EasyRapidlib.LearningTypeModel)
            {
                // Override model
                m_EasyRapidlib.OverrideModel(learningType);
            }

            // Make sure that any of the lists to use are null
            if (m_LengthsFeatureVector == null)
            {
                m_LengthsFeatureVector = new int[0];
            }
            if (m_Features == null)
            {
                m_Features = new List <FeaturesEnum>();
            }

            // Empty feature extractor delegate and populate with corresponding method
            m_ExtractFeatures      = null;
            m_LengthsFeatureVector = new int[m_Features.Count];
            for (int i = 0; i < m_Features.Count; i++)
            {
                switch (m_Features[i])
                {
                case FeaturesEnum.Position:
                    m_ExtractFeatures        += ExtractPosition;
                    m_LengthsFeatureVector[i] = 3;
                    break;

                case FeaturesEnum.Rotation:
                    m_ExtractFeatures        += ExtractRotation;
                    m_LengthsFeatureVector[i] = 4;
                    break;

                case FeaturesEnum.Velocity:
                    m_ExtractFeatures        += ExtractVelocity;
                    m_LengthsFeatureVector[i] = 3;
                    break;

                case FeaturesEnum.Acceleration:
                    m_ExtractFeatures        += ExtractAcceleration;
                    m_LengthsFeatureVector[i] = 3;
                    break;

                case FeaturesEnum.DistanceToFirstInput:
                    m_ExtractFeatures        += ExtractDistancesToFirstInput;
                    m_LengthsFeatureVector[i] = inputs.Length - 1;
                    break;

                case FeaturesEnum.Scale:
                    m_ExtractFeatures        += ExtractScale;
                    m_LengthsFeatureVector[i] = 3;
                    break;

                default:
                    break;
                }
            }
            // The last method in the delegate needs to be to reset the pointer for next iteration
            m_ExtractFeatures += ResetPointersFeatureVector;
        }