Exemplo n.º 1
0
        public void BackPropagateDropout(DropoutLayer layer)
        {
            var gradients      = layer.Gradients;
            var inputGradients = layer.InputGradients;
            var kernelCount    = gradients.Length;
            var dropoutMask    = layer.GetArray(ArrayName.DropoutMask);
            var dim            = ComputeBlocksTreads(kernelCount);

            Gpu.Launch(dim.Item1, dim.Item2).BPDropoutGPU(
                kernelCount,
                inputGradients.GPUArray,
                gradients.GPUArray,
                dropoutMask.GPUArray
                );
        }
Exemplo n.º 2
0
        public DropoutLayer AddDropoutLayer()
        {
            var lastLayer = Layers.Last();

            if (lastLayer == null)
            {
                throw new Exception("There must be one or more layers in the network");
            }
            //var convLayer = lastLayer as Conv1DLayer;
            //if (convLayer == null) throw new Exception("Last layer is not a conv1d layer");
            var layer = new DropoutLayer(_gpuModule, lastLayer);

            Layers.Add(layer);
            Console.WriteLine("Dropout layer.. ");
            return(layer);
        }
Exemplo n.º 3
0
        public void CalculateDropout(DropoutLayer layer, bool train)
        {
            var output      = layer.Outputs;
            var input       = layer.Inputs;
            var kernelCount = output.Length;
            var dropoutMask = layer.GetArray(ArrayName.DropoutMask);

            if (train)
            {
                this.Rand.GenerateUniform(dropoutMask.GPUArray);
            }
            var dim      = ComputeBlocksTreads(kernelCount);
            var trainVal = train ? 1f : 0f;

            Gpu.Launch(dim.Item1, dim.Item2).CalculateDropoutGPU(
                kernelCount,
                input.GPUArray,
                output.GPUArray,
                dropoutMask.GPUArray,
                0.5f,
                trainVal

                );
        }
Exemplo n.º 4
0
 public void BackPropagateDropout(DropoutLayer layer)
 {
     var gradients = layer.Gradients;
     var inputGradients = layer.InputGradients;
     var kernelCount = gradients.Length;
     var dropoutMask = layer.GetArray(ArrayName.DropoutMask);
     var dim = ComputeBlocksTreads(kernelCount);
     Gpu.Launch(dim.Item1, dim.Item2).BPDropoutGPU(
         kernelCount,
         inputGradients.GPUArray,
         gradients.GPUArray,
         dropoutMask.GPUArray
     );
 }
Exemplo n.º 5
0
        public void CalculateDropout(DropoutLayer layer, bool train)
        {
            var output = layer.Outputs;
            var input = layer.Inputs;
            var kernelCount = output.Length;
            var dropoutMask = layer.GetArray(ArrayName.DropoutMask);
            if (train)
            {
                this.Rand.GenerateUniform(dropoutMask.GPUArray);
            }
            var dim = ComputeBlocksTreads(kernelCount);
            var trainVal = train ? 1f : 0f;
            Gpu.Launch(dim.Item1, dim.Item2).CalculateDropoutGPU(
                kernelCount,
                input.GPUArray,
                output.GPUArray,
                dropoutMask.GPUArray,
                0.5f,
                trainVal

            );
        }
Exemplo n.º 6
0
 public DropoutLayer AddDropoutLayer()
 {
     var lastLayer = Layers.Last();
     if (lastLayer == null) throw new Exception("There must be one or more layers in the network");
     //var convLayer = lastLayer as Conv1DLayer;
     //if (convLayer == null) throw new Exception("Last layer is not a conv1d layer");
     var layer = new DropoutLayer(_gpuModule, lastLayer);
     Layers.Add(layer);
     Console.WriteLine("Dropout layer.. ");
     return layer;
 }