public override IVolume Forward(IVolume input, bool isTraining = false)
        {
            this.InputActivation = input;
            var output = input.Clone();
            var length = input.Length;

            if (isTraining)
            {
                // do dropout
                for (var i = 0; i < length; i++)
                {
                    if (Random.NextDouble() < this.DropProb)
                    {
                        output.Set(i, 0);
                        this.dropped[i] = true;
                    } // drop!
                    else
                    {
                        this.dropped[i] = false;
                    }
                }
            }
            else
            {
                // scale the activations during prediction
                for (var i = 0; i < length; i++)
                {
                    output.Set(i, output.Get(i) * (1 - this.DropProb));
                }
            }

            this.OutputActivation = output;
            return(this.OutputActivation); // dummy identity function for now
        }
Ejemplo n.º 2
0
            public override IVolume Forward(IVolume input, bool isTraining = false)
            {
                this.InputActivation = input;
                var output = input.Clone();

                Parallel.For(0, input.Length, i =>
                {
                    if (output.GetWeight(i) < 0)
                    {
                        output.SetWeight(i, 0);     // threshold at 0
                    }
                });
                this.OutputActivation = output;
                return(this.OutputActivation);
            }
Ejemplo n.º 3
0
        public override IVolume Forward(IVolume input, bool isTraining = false)
        {
            this.InputActivation = input;
            var output = input.Clone();

#if PARALLEL
            Parallel.For(0, input.Length, i =>
#else
            for (var i = 0; i < length; i++)
#endif
            {
                if (output.Get(i) < 0)
                {
                    output.Set(i, 0); // threshold at 0
                }
            }
Ejemplo n.º 4
0
 public IVolume ClonePlan(IVolume original)
 {
     return(AddPlan(original.Clone(), original));
 }