Пример #1
0
        /// <summary>
        /// Construct a network analyze class.  Analyze the specified network.
        /// </summary>
        /// <param name="network">The network to analyze.</param>
        public AnalyzeNetwork(BasicNetwork network)
        {
            int            assignDisabled = 0;
            int            assignedTotal  = 0;
            IList <double> biasList       = new List <double>();
            IList <double> weightList     = new List <double>();
            IList <double> allList        = new List <double>();

            foreach (ILayer layer in network.Structure.Layers)
            {
                if (layer.HasBias)
                {
                    for (int i = 0; i < layer.NeuronCount; i++)
                    {
                        biasList.Add(layer.BiasWeights[i]);
                        allList.Add(layer.BiasWeights[i]);
                    }
                }
            }

            foreach (ISynapse synapse in network.Structure.Synapses)
            {
                if (synapse.MatrixSize > 0)
                {
                    for (int from = 0; from < synapse.FromNeuronCount; from++)
                    {
                        for (int to = 0; to < synapse.ToNeuronCount; to++)
                        {
                            if (network.IsConnected(synapse, from, to))
                            {
                                double d = synapse.WeightMatrix[from, to];
                                weightList.Add(d);
                                allList.Add(d);
                            }
                            else
                            {
                                assignDisabled++;
                            }
                            assignedTotal++;
                        }
                    }
                }
            }

            this.disabledConnections = assignDisabled;
            this.totalConnections    = assignedTotal;
            this.weights             = new NumericRange(weightList);
            this.bias           = new NumericRange(biasList);
            this.weightsAndBias = new NumericRange(allList);
            this.weightValues   = EngineArray.ListToDouble(weightList);
            this.allValues      = EngineArray.ListToDouble(allList);
            this.biasValues     = EngineArray.ListToDouble(biasList);
        }
Пример #2
0
        /// <summary>
        /// Construct a network analyze class. Analyze the specified network.
        /// </summary>
        ///
        /// <param name="network">The network to analyze.</param>
        public AnalyzeNetwork(BasicNetwork network)
        {
            int            assignDisabled = 0;
            int            assignedTotal  = 0;
            IList <Double> biasList       = new List <Double>();
            IList <Double> weightList     = new List <Double>();
            IList <Double> allList        = new List <Double>();

            for (int layerNumber = 0; layerNumber < network.LayerCount - 1; layerNumber++)
            {
                int fromCount     = network.GetLayerNeuronCount(layerNumber);
                int fromBiasCount = network
                                    .GetLayerTotalNeuronCount(layerNumber);
                int toCount = network.GetLayerNeuronCount(layerNumber + 1);

                // weights
                for (int fromNeuron = 0; fromNeuron < fromCount; fromNeuron++)
                {
                    for (int toNeuron = 0; toNeuron < toCount; toNeuron++)
                    {
                        double v = network.GetWeight(layerNumber, fromNeuron,
                                                     toNeuron);

                        if (network.Structure.ConnectionLimited)
                        {
                            if (Math.Abs(v) < network.Structure.ConnectionLimit)
                            {
                                assignDisabled++;
                            }
                        }

                        weightList.Add(v);
                        allList.Add(v);
                        assignedTotal++;
                    }
                }

                // bias
                if (fromCount != fromBiasCount)
                {
                    int biasNeuron = fromCount;
                    for (int toNeuron = 0; toNeuron < toCount; toNeuron++)
                    {
                        double v = network.GetWeight(layerNumber, biasNeuron,
                                                     toNeuron);
                        if (network.Structure.ConnectionLimited)
                        {
                            if (Math.Abs(v) < network.Structure.ConnectionLimit)
                            {
                                assignDisabled++;
                            }
                        }

                        biasList.Add(v);
                        allList.Add(v);
                        assignedTotal++;
                    }
                }
            }

            _disabledConnections = assignDisabled;
            _totalConnections    = assignedTotal;
            _weights             = new NumericRange(weightList);
            _bias           = new NumericRange(biasList);
            _weightsAndBias = new NumericRange(allList);
            _weightValues   = EngineArray.ListToDouble(weightList);
            _allValues      = EngineArray.ListToDouble(allList);
            _biasValues     = EngineArray.ListToDouble(biasList);
        }