Beispiel #1
0
        public override Volume Forward(Volume input, bool isTraining = false)
        {
            this.InputActivation = input;
            var output = input.Clone();
            var length = input.Weights.Length;

            if (isTraining)
            {
                // do dropout
                for (var i = 0; i < length; i++)
                {
                    if (Random.NextDouble() < this.DropProb.Value)
                    {
                        output.Weights[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.Weights[i] *= 1 - this.DropProb.Value;
                }
            }

            this.OutputActivation = output;
            return(this.OutputActivation); // dummy identity function for now
        }
Beispiel #2
0
        public void CloneTest()
        {
            var vol   = new Volume(10, 10, 10);
            var clone = vol.Clone();

            for (int i = 0; i < vol.Length; i++)
            {
                Assert.AreEqual(vol.Get(i), clone.Get(i));
            }
        }
Beispiel #3
0
        public override Volume Forward(Volume input, bool isTraining = false)
        {
            this.InputActivation = input;
            var output = input.Clone();
            var length = input.Weights.Length;
            double[] outputWeights = output.Weights;

#if PARALLEL
            Parallel.For(0, length, i =>
#else
            for (var i = 0; i < length; i++)
#endif
            {
                if (outputWeights[i] < 0)
                {
                    outputWeights[i] = 0; // threshold at 0
                }
            }
 public void Mute()
 {
     _lastKnownVolume = Volume.Clone();
     Volume           = new Volume(0);
 }