Esempio n. 1
0
        public float[] Test(float[] iinput)
        {
            float[,] tinput = new float[1, ni];
            for (int i = 0; i < ni; i++)
            {
                tinput[0, i] = iinput[i];
            }

            dinput = new DFPA(tinput);
            diwt   = new DFPA(iwt);
            dowt   = new DFPA(owt);

            dtheta = PA.Section(dtheta, new Slice(0, 1), new Slice(0, nh));
            dtau   = PA.Section(dtau, new Slice(0, 1), new Slice(0, no));

            FPA t1      = PA.Add(PA.InnerProduct(dinput, diwt), dtheta);
            FPA ohidden = PA.Reciprocal(PA.Add(PA.Pow2(PA.Negate(t1)), 1.0f));
            FPA t2      = PA.Add(PA.InnerProduct(ohidden, dowt), dtau);

            FPA ooutput = PA.Reciprocal(PA.Add(PA.Pow2(PA.Negate(t2)), 1.0f));

            float[,] output;
            float[] routput = new float[no];
            PA.ToArray(ooutput, out output);

            for (int i = 0; i < no; i++)
            {
                routput[i] = output[0, i];
            }

            /*Disposable Floating arrays need to be explicitly "disposed" */
            dinput.Dispose();
            diwt.Dispose();
            dowt.Dispose();
            doutput.Dispose();

            /*Releasing all GPU Resources*/
            PA.UnInit();

            return(routput);
        }