/// <summary> /// 获取指定Name的节点 /// <para>TODO:建立索引搜索</para> /// </summary> /// <param name="name"></param> /// <returns></returns> public INeuralNode GetNode(string name, INeuralNode parentNode = null) { if (parentNode == null) { parentNode = Root; } INeuralNode foundNode = null; if (parentNode.Name == name) { foundNode = parentNode; } if (foundNode == null && parentNode.ChildrenNodes != null && parentNode.ChildrenNodes.Count > 0) { foreach (var node in parentNode.ChildrenNodes) { foundNode = GetNode(name, node);//监测当前节点 if (foundNode != null) { break; } } } return(foundNode); }
/// <summary> /// Initializes a new instance of the <see cref="NeuralConnection"/> class. /// </summary> /// <param name="initialWeight">The connection's initial weight value.</param> /// <param name="sourceNode">The source node.</param> /// <param name="targetNode">The target node.</param> public NeuralConnection(double initialWeight, INeuralNode sourceNode, INeuralNode targetNode) { if (sourceNode == null) { throw new ArgumentNullException("sourceNode"); } if (targetNode == null) { throw new ArgumentNullException("targetNode"); } // Initialize the class name that will appear in log files. this.name = sourceNode.Name + "->" + targetNode.Name; const string MethodName = "ctor"; Logger.TraceIn(this.name, MethodName); this.Weight = initialWeight; this.sourceNode = sourceNode; this.targetNode = targetNode; // Ensure that the end-point nodes have a reference to this connection object. this.sourceNode.AddOutboundConnection(this); this.targetNode.AddInboundConnection(this); Logger.TraceOut(this.name, MethodName); }
public LinkWeight(INeuralNode from, Neuron to) { this.Weight = RandomGenerator.Generate(); this.From = @from; this.To = to; this.From.AddOutput(this); this.PreviousDelta = 0; }
/// <summary> /// Adds a new output node to the network. /// </summary> /// <param name="node">The node.</param> public void AddOutputNode(INeuralNode node) { const string MethodName = "AddOutputNode"; Logger.TraceIn(this.name, MethodName); if (node == null) { throw new ArgumentNullException("node"); } if (!this.outputNodes.Contains(node)) { this.outputNodes.Add(node); } Logger.TraceOut(this.name, MethodName); }
/// <summary> /// 设置子节点 /// </summary> /// <param name="childNode"></param> public virtual void SetChildNode(INeuralNode childNode) { //childNode.SetParentNode(this); ChildrenNodes.Add(childNode); }
public HiddenNeuron(INeuralNode first, INeuralNode second) : base(first, second) { }
public OutputNeuron(INeuralNode first, INeuralNode second) : base(first, second) { }
/// <summary> /// 初始化 Root 参数 /// </summary> private void InitRoot() { INeuralNode root = new RootNeuralNode(); Root = root; }