public static DashboardTaskProperty CreateTaskProperty(MyTask task, string propertyName) { if (propertyName == null) { propertyName = "Enabled"; } return(new DashboardTaskProperty(task, task.GetType().GetProperty(propertyName))); }
/// <summary> /// Return task of given type from given node /// </summary> /// <param name="node">Node</param> /// <param name="type">Type of task</param> /// <returns>Task</returns> protected MyTask GetTaskByType(MyWorkingNode node, Type type) { foreach (PropertyInfo taskPropInfo in node.GetInfo().TaskOrder) { MyTask task = node.GetTaskByPropertyName(taskPropInfo.Name); if (task.GetType().ToString() == type.ToString()) { return(task); } } return(null); }
private string GenerateVariablesCode() { StringBuilder defs = new StringBuilder(); StringBuilder init = new StringBuilder(); init.AppendLine("public static void __InitGeneratedVariables(MyCSharpNodeGroup owner) { "); if (GenerateVariables) { foreach (string nodeIdentifier in m_nodeVariables.Keys) { MyNode node = GetChildNodeById(m_nodeVariables[nodeIdentifier]); string nodeTypeName = node.GetType().FullName.Replace('+', '.'); if (node != null) { defs.AppendLine("static " + nodeTypeName + " " + nodeIdentifier + ";"); init.AppendLine(nodeIdentifier + " = (" + nodeTypeName + ")owner.GetChildNodeById(" + node.Id + ");"); } } foreach (string taskIdentifier in m_taskVariables.Keys) { MyWorkingNode wNode = (MyWorkingNode)GetChildNodeById(m_taskVariables[taskIdentifier].Item1); MyTask task = wNode.GetTaskByPropertyName(m_taskVariables[taskIdentifier].Item2); if (task != null) { string taskTypeName = task.GetType().FullName.Replace('+', '.'); defs.AppendLine("static " + taskTypeName + " " + taskIdentifier + ";"); init.AppendLine(taskIdentifier + " = (" + taskTypeName + ")((MyWorkingNode)owner.GetChildNodeById(" + wNode.Id + ")).GetTaskByPropertyName(\"" + m_taskVariables[taskIdentifier].Item2 + "\");"); } } } init.AppendLine("}"); return(defs.ToString() + init.ToString()); }
private void UpdateWebBrowser() { if (Target != null) { string author; string status; string summary; string description; string include; m_mainForm.Documentation.HasAuthor(Target.GetType(), out author); CheckText(ref author); m_mainForm.Documentation.HasStatus(Target.GetType(), out status); CheckText(ref status); m_mainForm.Documentation.HasSummary(Target.GetType(), out summary); CheckText(ref summary); m_mainForm.Documentation.HasDescription(Target.GetType(), out description); CheckText(ref description); if (m_mainForm.Documentation.HasDocElement(Target.GetType(), "externdoc", out include)) { webBrowser.Navigate(include); } else { string html = "<html><head><meta http-equiv=\"X-UA-Compatible\" content=\"IE=11\"/>"; html += "<style type=\"text/css\">" + m_style + "</style></head><body>"; html += "<h1>" + Target.GetType().Name + "</h1>"; html += "<em>Author: " + author + "<br/> Status: " + status + "</em>"; html += "<p>" + summary + "</p>"; html += "<h2>Node description</h2>"; html += "<p>" + description + "</p>"; MyNodeInfo nodeInfo = Target.GetInfo(); if (Target is MyWorkingNode) { foreach (string taskName in nodeInfo.KnownTasks.Keys) { MyTask task = (Target as MyWorkingNode).GetTaskByPropertyName(taskName); Type taskType = task.GetType(); m_mainForm.Documentation.HasSummary(taskType, out summary); CheckText(ref summary); if (taskType.Name != task.Name) { html += "<h3>" + taskType.Name + " \u2014 " + task.Name + "</h3>"; } else { html += "<h3>" + taskType.Name + "</h3>"; } html += "<p>" + summary + "</p>"; } html += "</body></html>"; webBrowser.DocumentText = html; } } } }
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"); } }
public MyDebugTaskNode(MyTask task, Action enabledCallback) : base(task) { Icon = Properties.Resources.gears; OwnerName = task.GetType().Name; m_enabledCallback = enabledCallback; }
public MyDebugTaskNode(MyTask task) : base(task) { Icon = Properties.Resources.gears; OwnerName = task.GetType().Name; }