Example #1
0
 internal void RemoveConnection(Connection connection)
 {
     if(connection.FromNode == this) {
         OutgoingConnections.Remove(connection);
     } else if(connection.ToNode == this) {
         IncommingConnections.Remove(connection);
     }
 }
Example #2
0
 internal void AddOutgoingConnection(Connection connection)
 {
     if(connection.FromNode == this && connection.ToNode != null) {
         OutgoingConnections.Add(connection);
     } else {
         throw new ArgumentException("Invalid connection");
     }
 }
Example #3
0
        public static Connection Create(double weight, Node fromNode, Node toNode)
        {
            var con = new Connection(weight, fromNode, toNode);

            fromNode.AddOutgoingConnection(con);
            toNode.AddIncommingConnection(con);

            return con;
        }
Example #4
0
 public static void Delete(Connection connection)
 {
     connection.FromNode.RemoveConnection(connection);
     connection.ToNode.RemoveConnection(connection);
 }
Example #5
0
        /// <summary>
        /// Calculates connection influence value IF it is not yet present in ConnectionInfluence dictionary
        /// Stores result in the dictionary and then returns it
        /// </summary>
        private double GetConnectionInfluence(Connection connection, int microBatchIndex) {
            double? cur = ConnectionInfluence[connection][microBatchIndex];
            if(cur.HasValue) {
                return cur.Value;
            } else {
                double sumInfluenceOutput = 0;
                foreach(var outgoing in connection.ToNode.GetOutgoingConnections()) {
                    double connectionInfluence = GetConnectionInfluence(outgoing, microBatchIndex);
                    double curInfluence = connectionInfluence * outgoing.Weight;
                    sumInfluenceOutput += curInfluence;
                }

                double fromOutput = connection.FromNode.Output;
                double outDeriv = Network.TransferFunction.Derivative(connection.ToNode.Output);

                double influence = sumInfluenceOutput * outDeriv;
                ConnectionInfluence[connection][microBatchIndex] = influence;
                return influence;
            }
        }
Example #6
0
 private double CalcOutputInfuence(Connection connection, double expectedOutput, double actualOutput) {
     double dif = (-(expectedOutput - actualOutput));
     double outcome = dif * Network.TransferFunction.Derivative(actualOutput);
     return outcome;
 }