private void SelectWorldInWorldList(MyWorld world) { if (Properties.Settings.Default.ToolBarNodes == null) { Properties.Settings.Default.ToolBarNodes = new System.Collections.Specialized.StringCollection(); } // if the world is not present in the combo box, add it first if (!Properties.Settings.Default.ToolBarNodes.Contains(world.GetType().Name)) { Properties.Settings.Default.ToolBarNodes.Add(world.GetType().Name); worldList.Items.Add(MyConfiguration.KnownWorlds[Project.World.GetType()]); } worldList.SelectedItem = MyConfiguration.KnownWorlds[Project.World.GetType()]; }
private void ConnectWorld() { if (Network != null && World != null) { if (Network.InputBranches != World.OutputBranches) { Network.InputBranches = World.OutputBranches; Network.InitInputNodes(); } for (int i = 0; i < World.OutputBranches; i++) { Network.GroupInputNodes[i].Name = ShortenMemoryBlockName(World.GetOutput(i).Name); } if (Network.OutputBranches != World.InputBranches) { Network.OutputBranches = World.InputBranches; Network.InitOutputNodes(); } for (int i = 0; i < World.InputBranches; i++) { Network.GroupOutputNodes[i].Name = ShortenMemoryBlockName(MyNodeInfo.Get(World.GetType()).InputBlocks[i].Name); } for (int i = 0; i < World.OutputBranches; i++) { MyConnection worldToNetwork = new MyConnection(World, Network, i, i); worldToNetwork.Connect(); } for (int i = 0; i < World.InputBranches; i++) { MyConnection networkToWorld = new MyConnection(Network, World, i, i); networkToWorld.Connect(); } } }
public void CreatesAndRunsMNIST() { using (var runner = new MyProjectRunner()) { MyProject project = runner.CreateProject(typeof(MyMNISTWorld)); MyWorld world = project.World; var neuralGroup = project.CreateNode <MyNeuralNetworkGroup>(); project.Network.AddChild(neuralGroup); var hiddenLayer = project.CreateNode <MyHiddenLayer>(); neuralGroup.AddChild(hiddenLayer); var outputLayer = project.CreateNode <MyOutputLayer>(); neuralGroup.AddChild(outputLayer); var accumulator = project.CreateNode <MyAccumulator>(); neuralGroup.AddChild(accumulator); // Connect the nodes. project.Connect(project.Network.GroupInputNodes[0], neuralGroup, 0, 0); project.Connect(project.Network.GroupInputNodes[1], neuralGroup, 0, 1); project.Connect(neuralGroup.GroupInputNodes[0], hiddenLayer, 0, 0); project.Connect(neuralGroup.GroupInputNodes[1], outputLayer, 0, 1); project.Connect(hiddenLayer, outputLayer, 0, 0); project.Connect(outputLayer, accumulator, 1, 0); // Setup the nodes. MyTask sendMnistData = world.GetTaskByPropertyName("SendTrainingMNISTData"); Assert.NotNull(sendMnistData); sendMnistData.GetType().GetProperty("RandomEnumerate").SetValue(sendMnistData, true); sendMnistData.GetType().GetProperty("ExpositionTime").SetValue(sendMnistData, 1); world.GetType().GetProperty("Binary").SetValue(world, true); hiddenLayer.Neurons = 40; accumulator.ApproachValue.ApproachMethod = MyAccumulator.MyApproachValueTask.SequenceType.Momentum; accumulator.ApproachValue.Delta = 0.1f; accumulator.ApproachValue.Target = 0; accumulator.ApproachValue.Factor = 0.9f; // Enable tasks. project.World.EnableDefaultTasks(); neuralGroup.EnableDefaultTasks(); neuralGroup.RMS.Enabled = true; hiddenLayer.EnableDefaultTasks(); outputLayer.EnableDefaultTasks(); accumulator.EnableDefaultTasks(); accumulator.ApproachValue.Enabled = true; // Run the simulation. runner.RunAndPause(100); float error = runner.GetValues(accumulator.Id)[0]; Assert.True(error < 0.5f); //runner.SaveProject(@"c:\foobar.brain"); } }