Exemplo n.º 1
0
        public ValidationForm(MainForm mainForm)
        {
            InitializeComponent();
            Validator = new MyValidator();

            m_mainForm = mainForm;
        }
Exemplo n.º 2
0
 public override void Validate(MyValidator validator)
 {
     base.Validate(validator);
     validator.AssertError(Controls != null, this, "Controls must not be null");
     if (Controls != null)
         validator.AssertError(Controls.Count >= 3, this, "Size of Control input must be 3 or more");
 }
Exemplo n.º 3
0
        public ValidationForm(MainForm mainForm, MyValidator validator)
        {
            InitializeComponent();
            Validator = validator;

            m_mainForm = mainForm;
        }
Exemplo n.º 4
0
        public MyLocalSimulation(MyValidator validator, IMyExecutionPlanner executionPlanner)
            : base(validator)
        {
            m_threadPool = new MyThreadPool(MyKernelFactory.Instance.DevCount, InitCore, ExecutePlan);
            m_threadPool.StartThreads();

            try
            {
                ExecutionPlanner = executionPlanner;
            }
            catch (Exception e)
            {
                m_threadPool.Finish();
                throw e;
            }
        }
Exemplo n.º 5
0
        public override void Validate(MyValidator validator)
        {
            base.Validate(validator);

            if (PupilControl != null)
            {
                validator.AssertError(PupilControl.Count > 2, this, "Not enough control values (at least 3 values needed)");

                validator.AssertError((PupilControl.Count % 3) == 0, this, "Wrong pupil control input size, it has to be [x,y,s] or [x,y,s;x,y,s...]");
                validator.AssertError((float)PupilControl.Count / (float)PupilControl.ColumnHint != 0, this, "If input is matrix, it has to be 3 columns and N rows, each row x,y,s");
            }
        }
Exemplo n.º 6
0
        public override void Validate(MyValidator validator)
        {
            ScriptCheckMethod = null;
            ScriptShouldStopMethod = null;

            CSharpCodeProvider codeProvider = new CSharpCodeProvider();
            CompilerParameters parameters = new CompilerParameters()
            {
                GenerateInMemory = false,
                GenerateExecutable = false,

            };

            parameters.ReferencedAssemblies.Add("GoodAI.Platform.Core.dll");
            parameters.ReferencedAssemblies.Add("System.Core.dll"); //for LINQ support
            parameters.ReferencedAssemblies.Add("System.Runtime.dll"); //for LINQ support
            // TODO: load the xunit dll in Brain Simulator UI from the module directory.
            parameters.ReferencedAssemblies.Add("xunit.assert.dll");
            parameters.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);

            //Assembly[] loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
            //IEnumerable<Assembly> openTKAssemblies = loadedAssemblies.Where(x => x.ManifestModule.Name == "xunit.assert.dll");
            //if (openTKAssemblies.Count() > 0)
            //    parameters.ReferencedAssemblies.Add(openTKAssemblies.First().Location);

            CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, Script);

            if (results.Errors.HasErrors)
            {
                string message = "";

                foreach (CompilerError error in results.Errors)
                {
                    message += "Line " + error.Line + ": " + error.ErrorText + "\n";
                }

                validator.AddError(this, "Errors in compiled script:\n" + message);
                return;
            }
            else if (results.CompiledAssembly == null)
            {
                validator.AddError(this, "Compiled assembly is null.");
                return;
            }

            try
            {
                Type enclosingType = results.CompiledAssembly.GetType("Runtime.Script");

                ScriptCheckMethod = enclosingType.GetMethod("Check");
                validator.AssertError(ScriptCheckMethod != null, this, "Check() method not found in compiled script");

                ScriptShouldStopMethod = enclosingType.GetMethod("ShouldStop");  // optional, don't check for null
            }
            catch (Exception e)
            {
                validator.AddError(this, "Script analysis failed: " + e.GetType().Name + ": " + e.Message);
            }
        }
        public override void Validate(MyValidator validator)
        {
            base.Validate(validator);

            if (ControlsB != null)
            {
                validator.AssertError(ControlsB.Count >= 3, this, "Not enough controls (3 expected)");
            }
        }
Exemplo n.º 8
0
        public override void Validate(MyValidator validator)
        {
            //MyLog.INFO.WriteLine("In.c = " + Input.Count + " "+ (Input.Count != 9));
            //MyLog.INFO.WriteLine("Out.c = " + Action.Count + " " + (+Action.Count != 9));

            base.Validate(validator);
            //            validator.AssertWarning(XInput.Count == 1 && YInput.Count == 1, this, "Both inputs should have size 1. Only first value will be considered.");
            validator.AssertError(EnvironmentData==null || EnvironmentData.Count == 10 ,this, "EnvironmentData input has to have size 10.");

            var explore_rate = this.InitialExploration;
            var exploration_decay = this.ExplorationDecay;
            validator.AssertError(!(explore_rate < 0.0 || explore_rate > 1.0 || exploration_decay < 0.0 || exploration_decay > 1.0), this, "exploration parameters have to be in [0,1]");
        }
Exemplo n.º 9
0
        //Validation rules
        public override void Validate(MyValidator validator)
        {
            validator.AssertError((InputHeight - FilterHeight + 2 * ZeroPadding) % VerticalStride == 0, this, "Filter doesn't fit vertically when striding.");

            validator.AssertError((InputWidth - FilterWidth + 2 * ZeroPadding) % HorizontalStride == 0, this, "Filter doesn't fit horizontally when striding.");

            validator.AssertInfo(ZeroPadding == (FilterWidth - 1) / 2 && ZeroPadding == (FilterHeight - 1) / 2, this, "Input and output might not have the same dimension. Set stride to 1 and zero padding to ((FilterSize - 1) / 2) to fix this.");
        }
Exemplo n.º 10
0
        public override void Validate(MyValidator validator)
        {
            validator.AssertError(Controls != null, this, "No controls available");

            validator.AssertError(File.Exists(SaveFile), this, "Please specify a correct SaveFile path in world properties.");
            validator.AssertError(File.Exists(TilesetTable), this, "Please specify a correct TilesetTable path in world properties.");

            validator.AssertError(FoFSize > 0, this, "FoF size has to be positive.");
            validator.AssertError(FoFResWidth > 0, this, "FoF resolution width has to be positive.");
            validator.AssertError(FoFResHeight > 0, this, "FoF resolution height has to be positive.");
            validator.AssertError(FoVSize > 0, this, "FoV size has to be positive.");
            validator.AssertError(FoVResWidth > 0, this, "FoV resolution width has to be positive.");
            validator.AssertError(FoVResHeight > 0, this, "FoV resolution height has to be positive.");
            validator.AssertError(Width > 0, this, "Free view width has to be positive.");
            validator.AssertError(Height > 0, this, "Free view height has to be positive.");
            validator.AssertError(ResolutionWidth > 0, this, "Free view resolution width has to be positive.");
            validator.AssertError(ResolutionHeight > 0, this, "Free view resolution height has to be positive.");
            validator.AssertError(ToolSize > 0, this, "Tool size has to be positive.");
            validator.AssertError(ToolResWidth > 0, this, "Tool resolution width has to be positive.");
            validator.AssertError(ToolResHeight > 0, this, "Tool resolution height has to be positive.");

            ControlMapper.CheckControlSize(validator, Controls, this);

            TryToyWorld();

            foreach (TWLogMessage message in TWLog.GetAllLogMessages())
                switch (message.Severity)
                {
                    case TWSeverity.Error:
                        {
                            validator.AssertError(false, this, message.ToString());
                            break;
                        }
                    case TWSeverity.Warn:
                        {
                            validator.AssertWarning(false, this, message.ToString());
                            break;
                        }
                }
        }
Exemplo n.º 11
0
        public override void Validate(MyValidator validator)
        {
            base.Validate(validator);

            if (PreviousLayer != null)
            {
                MyLog.WARNING.WriteLine("Deltas are not propagated backwards from LSTM layer!");
            }
        }
Exemplo n.º 12
0
        public override void Validate(MyValidator validator)
        {
            base.Validate(validator);

            if (!ParamsChanged)
            {
                validator.AssertError(Layers.Count > 0, this, "The network has no layers.");

                validator.AssertError(DataInput != null, this, "No input available.");
                if (DataInput != null)
                {
                    validator.AssertError(DataInput.Count > 0, this, "Input connected but empty.");
                    validator.AssertWarning(DataInput.ColumnHint > 1, this, "The Data input columnHint is 1.");
                    uint total = InputWidth * InputHeight * InputsCount * ForwardSamplesPerStep;
                    validator.AssertError(DataInput.Count == total, this, "DataInput Count is " + DataInput.Count + ". Expected " + InputLayer.Output.ToString() + " = " + total + ".");
                }

                validator.AssertError(TrainingData != null, this, "No TrainingData available.");
                if (TrainingData != null)
                {
                    validator.AssertError(TrainingData.Count > 0, this, "TrainingData connected but empty.");
                    validator.AssertWarning(TrainingData.ColumnHint > 1, this, "TrainingData columnHint is 1.");
                    uint total = InputWidth * InputHeight * InputsCount * TrainingSamplesPerStep;
                    validator.AssertError(TrainingData.Count == total, this, "TrainingData Count is " + TrainingData.Count + ". Expected " + InputLayer.Output.ToString() + " = " + total + ".");
                }

                validator.AssertError(TrainingLabel != null, this, "No TrainingLabel available.");
                validator.AssertError(LastLayer != null, this, "Last layer is null.");
                if (TrainingLabel != null && LastLayer != null)
                    validator.AssertError(TrainingLabel.Count == LastLayer.Output.Count * TrainingSamplesPerStep, this, "Current label dimension is " + TrainingLabel.Count + ". Expected " + TrainingSamplesPerStep + "x" + LastLayer.Output.Count + ".");
            }
        }
Exemplo n.º 13
0
 public override void Validate(MyValidator validator)
 {
     //base.Validate(validator);
     validator.AssertError(Neurons > 0, this, "Number of neurons should be > 0");
     validator.AssertError(Input != null, this, "Neural network node \"" + this.Name + "\" has no input.");
     validator.AssertWarning(Connection != ConnectionType.NOT_SET, this, "ConnectionType not set for " + this);
 }
Exemplo n.º 14
0
        public override void Validate(MyValidator validator)
        {
            base.Validate(validator);

            if (!ParamsChanged)
            {
                validator.AssertError(Layers.Count > 0, this, "The network has no layers.");
                if (AutoencoderTask.NetworkMode != MyAutoencoderMode.FEATURE_DECODING)
                {
                    validator.AssertError(DataInput != null, this, "No input available.");
                    if (DataInput != null)
                    {
                        validator.AssertError(DataInput.Count > 0, this, "Input connected but empty.");
                        validator.AssertWarning(DataInput.ColumnHint > 1, this, "The Data input columnHint is 1.");
                        uint total = InputWidth * InputHeight * InputsCount * ForwardSamplesPerStep;
                        validator.AssertError(DataInput.Count == total, this, "DataInput Count is " + DataInput.Count + ". Expected " + InputLayer.Output.ToString() + " = " + total + ".");
                    }
                }

                if (AutoencoderTask.NetworkMode == MyAutoencoderMode.TRAINING)
                {
                    validator.AssertError(LastLayer != null, this, "Last layer is null.");
                }

                if (AutoencoderTask.NetworkMode == MyAutoencoderMode.FEATURE_ENCODING || AutoencoderTask.NetworkMode == MyAutoencoderMode.FEATURE_DECODING)
                {
                    validator.AssertError(FeatureLayer != null, this, "In FEATURE_ENCODING or FEATURE_DECODING mode, a featureLayer must be present in the network architecture");
                }

                if (AutoencoderTask.NetworkMode == MyAutoencoderMode.FEATURE_ENCODING)
                {
                    if (FeatureOutput != null && FeatureLayer != null)
                        validator.AssertError(FeatureOutput.Count == FeatureLayer.Output.Count * ForwardSamplesPerStep, this, "In FEATURE_DECODING mode, the Feature output must have the same size (currently " + FeatureOutput.Count + ") as the featureLayer output (" + FeatureLayer.Output.Count + " x " + ForwardSamplesPerStep + ")");
                }
                if (AutoencoderTask.NetworkMode == MyAutoencoderMode.FEATURE_DECODING)
                {
                    validator.AssertError(FeatureInput != null, this, "In FEATURE_DECODING mode, the Feature input must be connected");
                    if (FeatureInput != null && FeatureLayer != null)
                        validator.AssertError(FeatureInput.Count == FeatureLayer.Output.Count * ForwardSamplesPerStep, this, "In FEATURE_DECODING mode, the Feature input must have the same size (currently " + FeatureInput.Count + ") as the featureLayer output (" + FeatureLayer.Output.Count + " x " + ForwardSamplesPerStep + ")");
                }
            }
        }
Exemplo n.º 15
0
 public override void Validate(MyValidator validator)
 {
     base.Validate(validator);
     validator.AssertError(Target != null, this, "Target not defiend");
 }
Exemplo n.º 16
0
        public override void Validate(MyValidator validator)
        {
            base.Validate(validator);
            validator.AssertError(Input.Count != 0, this, "Zero input size is not allowed.");

            base.Validate(validator);
            validator.AssertError(Reward.Count != 0, this, "Zero reward size is not allowed.");
        }
 public MyCsvFileWriterNodeTests()
 {
     m_validator = TypeMap.GetInstance<MyValidator>();
 }
Exemplo n.º 18
0
        public static void CheckControlSize(MyValidator validator, MyAbstractMemoryBlock controls, MyWorkingNode sender)
        {
            validator.AssertError(controls != null, sender, "Controls are not connected");

            if (controls != null)
            {
                int neededControls = NrOfControls;
                int providedControls = controls.Count;
                validator.AssertError(providedControls >= neededControls, sender, String.Format("Wrong number of actions. With current control mode ({0}) you have to provide at least {1} controls. Provide the correct number of controls or change the control mode.", Mode, neededControls));
                validator.AssertWarning(providedControls != neededControls, sender, String.Format("With current control mode ({0}) you should provide {1} controls but you provided {2} controls. Make sure that this is what you want and you have correct control mode chosen.", Mode, neededControls, providedControls));
            }
        }
Exemplo n.º 19
0
 public override void Validate(MyValidator validator)
 {
     base.Validate(validator);
     if (ParentNetwork == null)
     {
         validator.AddError(this, "LSTM layer needs to be in a neural network group");
     }
 }
 public override void Validate(MyValidator validator)
 {
     validator.AssertError(Input.Count % 2 == 0, this, "Number of neurons in previous layer has to be even (two params mu, sigma).");
 }
Exemplo n.º 21
0
 public override void Validate(MyValidator validator)
 {
     base.Validate(validator); // commented out, so we don't explicitly need a target input
     validator.AssertError(Input != null, this, "No input available");
     validator.AssertError(Input.Count == Output.Count, this, "Input size must be equal to output size.");
 }
Exemplo n.º 22
0
 //Validation rules
 public override void Validate(MyValidator validator)
 {
     base.Validate(validator);
     if (QLearning.Enabled)
     {
         validator.AssertError(Action.Count == Neurons, this, "Number of neurons need to correspond with number of actions (action size)");
         validator.AssertError(Reward.Count == 1, this, "Reward needs to be a single floating point number (cannot be an array)");
     }
     else if (QLearningBatch.Enabled)
     {
         validator.AssertError(ParentNetwork.BatchSize >= 3, this, "BatchSize needs to be >= 3");
         validator.AssertError(Reward.Count == (ParentNetwork.BatchSize - 1) / 2, this, "Reward size must be equal to (BatchSize - 1) / 2");
         validator.AssertError(Action.Count == (ParentNetwork.BatchSize - 1) / 2 * Actions, this, "Action size must be equal to (BatchSize - 1) / 2 * Actions");
     }
 }
Exemplo n.º 23
0
 //Validation rules
 public override void Validate(MyValidator validator)
 {
     base.Validate(validator);
     validator.AssertError(Action.Count == Neurons, this, "Number of neurons need to correspond with number of actions (action size)");
     validator.AssertError(Reward.Count == 1, this, "Reward needs to be a single floating point number (cannot be an array)");
 }
Exemplo n.º 24
0
        public MySimulation(MyValidator validator)
        {
            AutoSaveInterval = 0;
            GlobalDataFolder = String.Empty;

            Validator = validator;
            validator.Simulation = this;
        }
Exemplo n.º 25
0
 public override void Validate(MyValidator validator)
 {
     base.Validate(validator);
 }
Exemplo n.º 26
0
        public override void Validate(MyValidator validator)
        {
            base.Validate(validator);

            List<IMyExecutable> tasks = GetTasks(this);

            validator.AssertError(tasks.Find(task => task is IMyForwardTask) != null, this, "You need to have at least one forward task");

            if (BatchSize > 1)
            {
                foreach (MyNode n in Children)
                {
                    var layer = n as MyAbstractLayer;
                    if (layer != null && !layer.SupportsBatchLearning)
                    {
                        validator.AssertError(false, layer, layer.Name + " does not support batch learning! Remove the layer or set BatchSize to 1.");
                    }
                }
            }
        }
Exemplo n.º 27
0
 public override void Validate(MyValidator validator)
 {
     //            base.Validate(validator);
     validator.AssertError(Neurons > 0, this, "Number of neurons should be > 0");
     validator.AssertWarning(Connection != ConnectionType.NOT_SET, this, "ConnectionType not set for " + this);
 }
        public override void Validate(MyValidator validator)
        {
            base.Validate(validator);

            if (validator.ValidationSucessfull)
            {
                // all inputs have equal size (so take first and check others)
                for (int i = 1, size = GetInputSize(0); i < InputBranches; i++)
                {
                    validator.AssertError(size == GetInputSize(i), this, "All inputs must be the same size");
                }
                validator.AssertError(InputBranches >= 2, this, "At least one target and one input have to be set");
            }
        }
Exemplo n.º 29
0
 public override void Validate(MyValidator validator)
 {
     validator.AssertError(Fitness != null, this, "Requires fitness input.");
     validator.AssertError(SwitchMember != null, this, "There must be a signal to change tested members. Otherwise infinite loops will occur.");
 }
Exemplo n.º 30
0
        //Validation rules
        public override void Validate(MyValidator validator)
        {
            base.Validate(validator);

            if (PreviousLayer != null)
                validator.AssertError(InputWidth * InputHeight * Depth == PreviousLayer.Neurons, this, "'Input width * input height * depth' must be equal to output size of the previous layer.");

            validator.AssertError((InputWidth - FilterWidth) % HorizontalStride == 0, this, "Filter does not fit the input image horizontally when striding.");

            // horizontal input check:
            validator.AssertError((InputHeight - FilterHeight) % VerticalStride == 0, this, "Filter does not fit the input image vertically when striding.");

            // vertical input check:
            validator.AssertError(InputHeight > FilterHeight && InputWidth > FilterWidth, this, "Filter dimensions must be smaller than input dimensions.");
        }