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> > >();
            }
        }
        public FullyConnectedLayer2D(Size outputSize, int sliceCount, Layer2D prevLayer, string activationFunction) : base(prevLayer, activationFunction, sliceCount)
        {
            var x   = (int)outputSize.Width;
            var y   = (int)outputSize.Height;
            var fac = GetSuitableFactorForFunction(function, x * y);

            for (int i = 0; i < sliceCount; i++)
            {
                float[] source = { Config.learningRate, fac };
                this.variable[i]  = GPUHelper.CreateBuffer(source, 2);
                this.bias[i]      = GPUHelper.CreateBuffer(x, y);
                this.activated[i] = GPUHelper.CreateBuffer(x, y);
                this.sumInput[i]  = GPUHelper.CreateBuffer(x, y);
                this.error[i]     = GPUHelper.CreateBuffer(x, y);
                this.weight[i]    = GPUHelper.CreateBuffer(x, y, this.GetWeightCount());
                this.derived[i]   = GPUHelper.CreateBuffer(x, y);
            }
        }
        public ConvolutionalLayer2D(int radius, int sliceCount, Layer2D prevLayer, string activationFunction) : base(prevLayer, activationFunction, sliceCount)
        {
            this.radius = radius;
            var x = (int)prevLayer.GetActivatedBuffer(0).Extent.X;
            var y = (int)prevLayer.GetActivatedBuffer(0).Extent.Y;

            this.fac = GetSuitableFactorForFunction(function, (2 * radius + 1) * (2 * radius + 1));
            for (int i = 0; i < sliceCount; i++)
            {
                float[] source = { Config.learningRate, fac, radius };
                this.variable[i]  = GPUHelper.CreateBuffer(source, source.Length);
                this.bias[i]      = GPUHelper.CreateBuffer(x, y);
                this.activated[i] = GPUHelper.CreateBuffer(x, y);
                this.sumInput[i]  = GPUHelper.CreateBuffer(x, y);
                this.error[i]     = GPUHelper.CreateBuffer(x, y);
                this.weight[i]    = GPUHelper.CreateBuffer(x, y, this.GetWeightCount());
                this.derived[i]   = GPUHelper.CreateBuffer(x, y);
            }
        }
        public RandomLayer2D(Layer2D prevLayer, int sliceCount, int maxConnectionsPerNeuron) : base(prevLayer, null, sliceCount)
        {
            var x             = (int)prevLayer.GetActivatedBuffer(0).Extent.X;
            var y             = (int)prevLayer.GetActivatedBuffer(0).Extent.Y;
            var fac           = GetSuitableFactorForFunction(function, x * y);
            var weightFactory = new RandomMatrixFactory(x, y, maxConnectionsPerNeuron, RandomMatrixFactory.GenerationType.Float);
            var conFactory    = new RandomMatrixFactory(x, y, maxConnectionsPerNeuron * 2, RandomMatrixFactory.GenerationType.Integer, maxConnectionsPerNeuron);

            connectionInfo    = new MemoryBuffer3D <int> [sliceCount];
            newConnectionInfo = new MemoryBuffer3D <int> [sliceCount];
            for (int i = 0; i < sliceCount; i++)
            {
                float[] source = { Config.learningRate, fac };
                this.variable[i]  = GPUHelper.CreateBuffer(source, 2);
                this.bias[i]      = GPUHelper.CreateBuffer(x, y);
                this.activated[i] = GPUHelper.CreateBuffer(x, y);
                this.sumInput[i]  = GPUHelper.CreateBuffer(x, y);
                this.error[i]     = GPUHelper.CreateBuffer(x, y);
                this.weight[i]    = GPUHelper.CreateBuffer(x, y, maxConnectionsPerNeuron);
                this.derived[i]   = GPUHelper.CreateBuffer(x, y);
                bool b = true;
                while (b)
                {
                    if (conFactory.intQueue3D.Count > 1)
                    {
                        b = false;
                    }
                }
                int[,,] arr;
                conFactory.intQueue3D.TryDequeue(out arr);
                this.connectionInfo[i] = GPUHelper.CreateBuffer(arr, x, y, maxConnectionsPerNeuron * 2);
                conFactory.intQueue3D.TryDequeue(out arr);
                this.newConnectionInfo[i] = GPUHelper.CreateBuffer(arr, x, y, maxConnectionsPerNeuron * 2);
            }
            var extent = connectionInfo[0].Extent;
        }