AI-PSO

 view release on metacpan or  search on metacpan

examples/NeuralNet/NeuralNet.h  view on Meta::CPAN

        ///
        /// \fn void setHiddenWeight(int indexHidden, int indexInput, double weight)
        /// \brief sets the connection weight between a pair of input and hidden neurons
        /// \param indexHidden an int
        /// \param indexInput an int
        /// \param weight a double
        ///
        void setHiddenWeight(int indexHidden, int indexInput, double weight)
        {
            if(indexHidden >= 0 && indexHidden < m_numHidden)
                m_hidden[indexHidden].setWeight(indexInput, weight);
        }


        ///
        /// \fn void setOutputWeight(int index, double weight)
        /// \brief sets the connection weight between a pair of hidden and output neurons
        /// \param index an int
        /// \param weight a double
        ///
        void setOutputWeight(int index, double weight)
        {
            m_output.setWeight(index, weight);
        }

/*
        void read(istream & in)
        {
            in  >> m_numInputs
                >> m_numHidden;
            
            delete [] m_inputs;
            delete [] m_hidden;

            m_inputs = new Input[m_numInputs];
            m_hidden = new Neuron[m_numHidden];
            connectionize();

            double weight;

            for(int i = 0; i < m_numHidden; i++)
                for(int j = 0; j < m_hidden[i].numConnections(); j++)
                {
                    in >> weight;
                    m_hidden[i].setWeight(j, weight);
                }
            for(int k = 0; k < m_output.numConnections(); k++)
            {
                in >> weight;
                m_output.setWeight(k, weight);
            }
            
        }

        friend istream & operator>>(istream & in, NeuralNet & ann)
        {
            ann.read(in);
            return in;
        }

        void print(ostream & out)
        {
        }
*/
    protected:

        ///
        /// \fn connectionize()
        /// \brief builds a fully connected network once the Neurons are constructed
        /// 
        void connectionize()
        {
            for(int i = 0; i < m_numInputs; i++)
                for(int j = 0; j < m_numHidden; j++)
                    m_hidden[j].addConnection(&m_inputs[i]);

            for(int k = 0; k < m_numHidden; k++)
                m_output.addConnection(&m_hidden[k]);
        }


        int        m_numInputs;    /// number of input Neurons    in network
        int        m_numHidden;    /// number of hidden Neurons in network
        Input  *m_inputs;        /// array of Input Neurons
//        Neuron *m_hidden;        /// array of hidden Neurons
        Hidden *m_hidden;        /// array of hidden Neurons
        Neuron    m_output;        /// the single output Neuron (it is more efficient to have a separate network for each output)
        string  m_xferFunc;        /// type of transfer function for hidden neurons
};

#endif



( run in 0.531 second using v1.01-cache-2.11-cpan-fe3c2283af0 )