/// <summary>
        /// Pomnoziti sve ulaze sa tezinama.
        /// Sabrati sve rezultate mnozaca. Kao povratnu vrednost
        /// vratiti vrednost aktivacione funkije za vrednost suma
        /// svih mnozaca
        /// </summary>
        /// <param name="x">x is a vector of inputs</param>
        /// <returns></returns>
        public double forward(List <double> x)
        {
            List <double> inputs = new List <double>(x);

            inputs.Add(1.0); //bias

            List <double> forSum = new List <double>();

            //TODO 6: Izracunati vrednost na izlazu vestackog neurona
            for (int i = 0; i < inputs.Count; i++)
            {
                MultiplyNode mn     = this.multiplyNodes[i];
                double       weight = mn.x[1];

                List <double> newInputs = new List <double>();
                newInputs.Add(inputs[i]);
                newInputs.Add(weight);

                forSum.Add(mn.forward(newInputs));
            }

            double summed = this.sumNode.forward(forSum);
            double summed_act;


            if (activation.Equals("sigmoid"))
            {
                summed_act = this.activation_node.forward(summed);
            }
            else
            {
                summed_act = this.activation_node2.forward(summed);
            }
            return(summed_act);
        }
示例#2
0
        /// <summary>
        /// Pomnoziti sve ulaze sa tezinama.
        /// Sabrati sve rezultate mnozaca. Kao povratnu vrednost
        /// vratiti vrednost aktivacione funkije za vrednost suma
        /// svih mnozaca
        /// </summary>
        /// <param name="x">x is a vector of inputs</param>
        /// <returns></returns>
        public double forward(List <double> x)
        {
            /*
             * List<double> inputs = new List<double>(x);
             * inputs.Add(1.0); //bias
             *
             * List<double> forSum = new List<double>();
             * //TODO 6: Izracunati vrednost na izlazu vestackog neurona
             * for (int i = 0; i < inputs.Count; i++)
             * {
             *  double w_i = this.multiplyNodes[i].x[1]; //uzmi tezinu iz mnozackog cvora, drugi parametar
             *  MultiplyNode mn = new MultiplyNode();
             *
             *
             *  List<double> parTezinaInput = new List<double>();
             *
             *
             *  parTezinaInput.Add(w_i);
             *  parTezinaInput.Add(inputs[i]);
             *
             *  //mora ovako jer mn.forward trazi parametre
             *
             *
             *  //pomnozi i dodaj u buduci sabirac
             *  forSum.Add(mn.forward(parTezinaInput));
             *
             * }
             *
             * double summed = 0.0;
             * //SumNode sumNode = new SumNode();
             * summed = sumNode.forward(forSum);
             *
             * // dobijena vrednost se propusti kroz aktivacionu funkciju
             * double summed_act = this.activation_node.forward(summed);
             * return summed_act;
             */


            List <double> inputs = new List <double>(x);

            inputs.Add(1.0); //bias

            List <double> forSum = new List <double>();

            //TODO 6: Izracunati vrednost na izlazu vestackog neurona
            for (int i = 0; i < inputs.Count; i++)
            {
                MultiplyNode mn     = this.multiplyNodes[i];
                double       weight = mn.x[1];

                List <double> newInputs = new List <double>();
                newInputs.Add(inputs[i]);
                newInputs.Add(weight);

                forSum.Add(mn.forward(newInputs));
            }

            double summed = this.sumNode.forward(forSum);

            // dobijena vrednost se propusti kroz aktivacionu funkciju
            double summed_act = this.activation_node.forward(summed);

            return(summed_act);
        }