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 ); }
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); }
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 ); }
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; }