protected virtual void InitializeKernels() { if (sumCalculateFunction != null) { sumCalculate = GPUHelper.CreateKernel(sumCalculateFunction).CreateLauncherDelegate <Action <AcceleratorStream, Index2, ArrayView3D <float>, ArrayView2D <float>, ArrayView2D <float>, ArrayView2D <float>, ArrayView <float> > >(); } if (sumErrorFunction != null) { if (nextLayer != null) { sumForError = GPUHelper.CreateKernel(sumErrorFunction).CreateLauncherDelegate <Action <AcceleratorStream, Index2, ArrayView2D <float>, ArrayView2D <float>, ArrayView3D <float>, ArrayView2D <float>, ArrayView2D <float>, ArrayView <float> > >(); } else { sumForError = GPUHelper.CreateKernel(sumErrorFunction).CreateLauncherDelegate <Action <AcceleratorStream, Index2, ArrayView2D <float>, ArrayView2D <float>, ArrayView3D <float>, ArrayView2D <float>, ArrayView2D <float>, ArrayView <float> > >(); } } if (adjustWheigtsFunction != null) { adjustWheigts = GPUHelper.CreateKernel(adjustWheigtsFunction).CreateLauncherDelegate <Action <AcceleratorStream, Index2, ArrayView3D <float>, ArrayView2D <float>, ArrayView2D <float>, ArrayView2D <float>, ArrayView <float> > >(); } if (activationFunction != null) { activation = GPUHelper.CreateKernel(activationFunction).CreateLauncherDelegate <Action <AcceleratorStream, Index2, ArrayView2D <float>, ArrayView2D <float>, ArrayView <float> > >(); } if (derivationFunction != null) { derivation = GPUHelper.CreateKernel(derivationFunction).CreateLauncherDelegate <Action <AcceleratorStream, Index2, ArrayView2D <float>, ArrayView2D <float>, ArrayView <float> > >(); } }
internal InputLayer2D(Size dimensions, Layer2D prevLayer, int sliceCount, string function = null) : base(prevLayer, null, sliceCount) { this.inputs = new MemoryBuffer2D <float> [sliceCount]; var widthOutput = (int)dimensions.Width; var heightOutput = (int)dimensions.Height; for (int i = 0; i < sliceCount; i++) { this.inputs[i] = GPUHelper.CreateBuffer(widthOutput, heightOutput); this.activated[i] = GPUHelper.CreateBuffer(widthOutput, heightOutput); this.sumInput[i] = GPUHelper.CreateBuffer(widthOutput, heightOutput); } if (function != null) { MethodInfo methodInfo = Type.GetType("DeepDave.Layer.Kernels.NormalizationFunctions").GetMethod(function, BindingFlags.NonPublic | BindingFlags.Static); normalize = GPUHelper.CreateKernel(methodInfo).CreateLauncherDelegate <Action <AcceleratorStream, Index2, ArrayView2D <float>, ArrayView2D <float>, ArrayView <float> > >(); } }
protected override void InitializeKernels() { sumCalculateFunction = Type.GetType("DeepDave.Layer.Kernels.SumCalculate").GetMethod("FullyConnectedLayer2D", BindingFlags.NonPublic | BindingFlags.Static); activationFunction = Type.GetType("DeepDave.Layer.Kernels.ActivationFunctions").GetMethod("Softmax", BindingFlags.NonPublic | BindingFlags.Static); sumErrorFunction = Type.GetType("DeepDave.Layer.Kernels.SoftmaxFunctions").GetMethod("Error", BindingFlags.NonPublic | BindingFlags.Static); adjustWheigtsFunction = Type.GetType("DeepDave.Layer.Kernels.WheightAdjustment").GetMethod("FullyConnectedLayer2D", BindingFlags.NonPublic | BindingFlags.Static); var info = Type.GetType("DeepDave.Layer.Kernels.SoftmaxFunctions").GetMethod("SumActivatedOutputs", BindingFlags.NonPublic | BindingFlags.Static); sumActivatedOutputs = GPUHelper.CreateKernel(info).CreateLauncherDelegate <Action <AcceleratorStream, Index1, ArrayView <float>, ArrayView2D <float> > >(); info = Type.GetType("DeepDave.Layer.Kernels.SoftmaxFunctions").GetMethod("DivisionBySumActivatedOutputs", BindingFlags.NonPublic | BindingFlags.Static); divisionBySumActivatedOutputs = GPUHelper.CreateKernel(info).CreateLauncherDelegate <Action <AcceleratorStream, Index2, ArrayView <float>, ArrayView2D <float>, ArrayView2D <float> > >(); info = Type.GetType("DeepDave.Layer.Kernels.DerivativeFunctions").GetMethod("Softmax", BindingFlags.NonPublic | BindingFlags.Static); softmaxDerivative = GPUHelper.CreateKernel(info).CreateLauncherDelegate <Action <AcceleratorStream, Index2, ArrayView2D <float>, ArrayView2D <float> > >(); info = Type.GetType("DeepDave.Layer.Kernels.SoftmaxFunctions").GetMethod("Normalization", BindingFlags.NonPublic | BindingFlags.Static); softmaxNormalization = GPUHelper.CreateKernel(info).CreateLauncherDelegate <Action <AcceleratorStream, Index1, ArrayView2D <float> > >(); base.InitializeKernels(); }