Exemple #1
0
        //Functions
        public override double[] propagate(double[] Bids)
        {
            Mapack.Matrix BidM = new Matrix(new double[][] { Bids });

            //sanity check
            try
            {
                if (Bids.Length != W1.Rows)
                {
                    throw new Exception("The number of bids and weights does not match");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            int H = W1.Columns;
            int M = W1.Rows;
            int K = W2.Columns;

            Matrix a1 = W1.Transpose() * BidM.Transpose();
            Matrix Z  = new Matrix(H, 1);

            for (int h = 0; h < H; h++)
            {
                double d = a1[h, 0];
                Z[h, 0] = Math.Tanh(d);
            }
            Matrix a2 = W2.Transpose() * Z;

            double Denominator = 0;

            for (int k = 0; k < K; k++)
            {
                double d = a2[k, 0];
                d            = Math.Exp(d);
                Denominator += d;
            }

            double[] Probabilities = new double[K];
            for (int k = 0; k < K; k++)
            {
                double d = a2[k, 0];
                d = Math.Exp(d);
                Probabilities[k] = d / Denominator;
            }
            ///////Back up Data////////////////////////
            Zt  = Ztp;
            Bt  = Btp;
            Yt  = Ytp;
            Ztp = Z;
            Btp = BidM;
            Ytp = Probabilities;


            return(Probabilities);
        }