コード例 #1
0
        public List <Message>[] Run(List <Message>[] input, string printLocation = "")
        {
            messageHandling.resetLists();

            foreach (List <LeakyIntegrateAndFireNode> current_nodes in Nodes)
            {
                foreach (LeakyIntegrateAndFireNode n in current_nodes)
                {
                    n.ResetNode();
                    n.CurrentlyTraining = true;//training;
                }
            }

            //setup inputs
            for (int node_count = 0; node_count < Nodes[0].Count; node_count++)
            {
                foreach (Message message in input[node_count])
                {
                    messageHandling.addMessage(new Message(message.Time, InputSynapses[node_count], 1)); //add inputs
                }
            }

            //loop round current 'events' till none left
            while (messageHandling.RunEventsAtNextTime() && messageHandling.max_time < 1000)
            {
                foreach (List <LeakyIntegrateAndFireNode> current_layer in Nodes)
                {
                    foreach (LeakyIntegrateAndFireNode n in current_layer)
                    {
                        n.PostFire();
                    }
                }
            }

            if (printLocation != "")
            {
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(printLocation, true))
                {
                    file.Write("\n");
                    foreach (List <LeakyIntegrateAndFireNode> node_list in Nodes)
                    {
                        foreach (Node n in node_list)
                        {
                            {
                                file.Write((n.LastDeltaI * n.LastDeltaI).ToString() + ",");
                            }
                        }
                        file.Write("NEXTLAYER,");
                    }
                }
            }
            return(messageHandling.getOutput());
        }
コード例 #2
0
ファイル: Node.cs プロジェクト: beno11224/SNNLib
        public virtual void Spike(int time, double val = 1) //val for future use
        {
            if (CurrentlyTraining)
            {
                OutputMessages.Add(new Message(time, new SynapseObject(this, null), val));
            }

            foreach (SynapseObject output in Outputs)
            {
                messageHandler.addMessage(new Message(time + Delay, output, val));
            }
        }