public unsafe void SoftmaxTest()
        {
            float[] v1  = { 1, 2, 3, 1 };
            float[] res = new float[4];

            fixed(float *ptr_v1 = v1, ptr_res = res)
            VectorizationFloat.Softmax(ptr_v1, ptr_res, 2, v1.Length);

            float[] res2 = { 0.268932253f, 0.7310678f, 0.8808078f, 0.119192213f };
            //todo check the res
            //Assert.IsTrue(ArrayEqual(res, res2));
        }
        public unsafe void SoftmaxTest2()
        {
            float[] v1 = new float[128];

            for (int i = 0; i < v1.Length; i++)
            {
                v1[i] = 1;
            }

            float[] res = new float[128];

            fixed(float *ptr_v1 = v1, ptr_res = res)
            VectorizationFloat.Softmax(ptr_v1, ptr_res, 64, v1.Length);

            float[] res2 = new float[128];

            for (int i = 0; i < res2.Length; i++)
                res2[i] = 1f / 64; }
예제 #3
0
 public static void SoftmaxFloat32(Tensor res, Tensor v)
 {
     VectorizationFloat.Softmax((float *)v.Base.Array, (float *)res.Base.Array, v.Shape[v.Shape.N - 1], v.Shape.TotalSize);
 }