예제 #1
0
        public void Gate(Synapse connection)
        {
            // add connection to gated list
            Connections.Gated[connection.Id] = connection;

            var neuron = connection.Target;

            if (!(Trace.Extended.ContainsKey(neuron.Id)))
            {
                // extended trace
                _neighbors[neuron.Id] = neuron;
                var xtrace = _trace.Extended[neuron.Id] = new Dictionary <int, double>();
                for (var id = 0; id < _connections.Inputs.Count; id++)
                {
                    var input = _connections.Inputs[id];
                    xtrace[input.Id] = 0;
                }
            }

            // keep track
            if (Trace.Influences.ContainsKey(neuron.Id))
            {
                _trace.Influences[neuron.Id].Add(connection);
            }
            else
            {
                _trace.Influences[neuron.Id] = new List <Synapse> {
                    connection
                };
            }

            // set gater
            connection.Gater = this;
        }
예제 #2
0
        public Synapse Project(Neuron targetNeuron, double weight = 0)
        {
            // self-connection
            if (targetNeuron == this)
            {
                _selfconnection.Weight = 1;
                return(_selfconnection);
            }

            Synapse connection; //the new connection

            // check if connection already exists
            var connected = Connected(targetNeuron);

            if (connected != null && connected.Type == ConnectedNeuronType.Projected)
            {
                // update connection
                if (weight > 0)
                {
                    connected.Connection.Weight = weight;
                }
                // return existing connection
                return(connected.Connection);
            }
            else
            {
                // create a new connection
                connection = new Synapse(this, targetNeuron, weight);
            }

            // reference all the connections and traces
            _connections.Projected[connection.Id]          = connection;
            _neighbors[targetNeuron.Id]                    = targetNeuron;
            targetNeuron.Connections.Inputs[connection.Id] = connection;
            targetNeuron.Trace.Eligibility[connection.Id]  = 0;

            for (var id = 0; id < targetNeuron.Trace.Extended.Count; id++)
            {
                var trace = targetNeuron.Trace.Extended[id];
                trace[connection.Id] = 0;
            }

            return(connection);
        }
예제 #3
0
 public Neuron()
 {
     _selfconnection = new Synapse(this, this, 0);
 }