Encog.Neural.Networks.BasicNetwork.IsConnected C# (CSharp) Method

IsConnected() public method

Determine if the specified connection is enabled.
public IsConnected ( int layer, int fromNeuron, int toNeuron ) : bool
layer int The layer to check.
fromNeuron int The source neuron.
toNeuron int THe target neuron.
return bool
        public bool IsConnected(int layer, int fromNeuron,
                                int toNeuron)
        {
            /*
			 * if (!this.structure.isConnectionLimited()) { return true; } final
			 * double value = synapse.getMatrix().get(fromNeuron, toNeuron);
			 * 
			 * return (Math.abs(value) > this.structure.getConnectionLimit());
			 */
            return false;
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Randomize a synapse, only randomize those connections that are actually connected.
        /// </summary>
        /// <param name="network">The network the synapse belongs to.</param>
        /// <param name="synapse">The synapse to randomize.</param>
        public override void Randomize(BasicNetwork network, ISynapse synapse)
        {
            if (synapse.WeightMatrix != null)
            {
                bool limited = network.Structure.IsConnectionLimited;
                double[][] d = synapse.WeightMatrix.Data;
                for (int fromNeuron = 0; fromNeuron < synapse.WeightMatrix.Rows; fromNeuron++)
                {
                    for (int toNeuron = 0; toNeuron < synapse.WeightMatrix.Cols; toNeuron++)
                    {
                        if (!limited || network.IsConnected(synapse, fromNeuron, toNeuron))
                            d[fromNeuron][toNeuron] = CalculateValue(synapse.WeightMatrix.Rows);
                    }
                }

            }
        }