예제 #1
0
        public override Volume Forward(Volume input, bool isTraining = false)
        {
            this.InputActivation = input;
            var outputActivation = input.CloneAndZero();
            var length = input.Weights.Length;

#if PARALLEL
            Parallel.For(0, length, i =>
#else
            for (var i = 0; i < length; i++)
#endif
            { outputActivation.Weights[i] = Math.Tanh(input.Weights[i]); }
예제 #2
0
        public static Volume Flip(this Volume volume, FlipMode mode)
        {
            Volume result = volume;

            if (mode == FlipMode.LeftRight || mode == FlipMode.Both)
            {
                // flip volume horziontally
                var w = volume.CloneAndZero();
                for (var x = 0; x < volume.Width; x++)
                {
                    for (var y = 0; y < volume.Height; y++)
                    {
                        for (var depth = 0; depth < volume.Depth; depth++)
                        {
                            w.Set(x, y, depth, volume.Get(volume.Width - x - 1, y, depth)); // copy data over
                        }
                    }
                }
                result = w; //swap
            }

            if (mode == FlipMode.UpDown || mode == FlipMode.Both)
            {
                // flip volume horziontally
                var w = volume.CloneAndZero();
                for (var x = 0; x < volume.Width; x++)
                {
                    for (var y = 0; y < volume.Height; y++)
                    {
                        for (var depth = 0; depth < volume.Depth; depth++)
                        {
                            w.Set(x, y, depth, result.Get(x, volume.Height - y - 1, depth)); // copy data over
                        }
                    }
                }
                result = w; //swap
            }

            return(result);
        }
예제 #3
0
        public override Volume Forward(Volume input, bool isTraining = false)
        {
            this.InputActivation = input;
            var volume2 = input.CloneAndZero();
            var length = input.Weights.Length;
            double[] v2w = volume2.Weights;
            double[] vw = input.Weights;

            for (var i = 0; i < length; i++)
            {
                v2w[i] = 1.0 / (1.0 + Math.Exp(-vw[i]));
            }

            this.OutputActivation = volume2;
            return this.OutputActivation;
        }
예제 #4
0
        public override Volume Forward(Volume input, bool isTraining = false)
        {
            this.InputActivation = input;
            var volume2 = input.CloneAndZero();
            var length  = input.Weights.Length;

            double[] v2w = volume2.Weights;
            double[] vw  = input.Weights;

            for (var i = 0; i < length; i++)
            {
                v2w[i] = 1.0 / (1.0 + Math.Exp(-vw[i]));
            }

            this.OutputActivation = volume2;
            return(this.OutputActivation);
        }
예제 #5
0
        public override Volume Forward(Volume input, bool isTraining = false)
        {
            this.InputActivation = input;
            var outputActivation = input.CloneAndZero();
            var length = input.Weights.Length;

#if PARALLEL
            Parallel.For(0, length, i =>
#else
            for (var i = 0; i < length; i++)
#endif
            { outputActivation.Weights[i] = Math.Tanh(input.Weights[i]); }
#if PARALLEL
);
#endif
            this.OutputActivation = outputActivation;
            return this.OutputActivation;
        }