Пример #1
0
        public static void Activation_Sigmoid(Tensor input, Tensor output)
        {
            __m256 one = Vector256.Create(1.0f);

            for (int i = 0; i < output.xmm.Length; ++i)
            {
                output.xmm[i] = NN_utils.exp256_ps(input.xmm[i]);
                var divisor = Avx2.Add(output.xmm[i], one);
                output.xmm[i] = Avx2.Divide(output.xmm[i], divisor);
            }
        }
Пример #2
0
        public static void  Activation_Softmax(Tensor input, Tensor output)
        {
            float sum = 0.0f;

            for (int i = 0; i < output.xmm.Length; ++i)
            {
                output.xmm[i] = NN_utils.exp256_ps(input.xmm[i]);
                sum          += NN_utils.hsums(output.xmm[i]).GetElement <float>(0);
            }
            sum = 1.0f / sum;
            output.mul(sum, output);
        }