示例#1
0
        protected override void Build(BufferAllocator allocator, ConnectedLayerGroups connectedLayerGroups, NNInitParameters initPars)
        {
            InitializeInputAndOutput(connectedLayerGroups);

            BuildForwardComputation(allocator, connectedLayerGroups, (CPUNNInitParameters)initPars);
            if (IsBackwardEnabled) BuildBackwardComputation(connectedLayerGroups);
        }
 protected override void Build(BufferAllocator allocator, ConnectedLayerGroups connectedLayerGroups, NNInitParameters initPars)
 {
     var oclInitPars = (OpenCLNNInitParameters)initPars;
     CreateOpenCLContext(oclInitPars);
     inputBuffer = connectedLayerGroups.InputBuffer;
     outputBuffer = connectedLayerGroups.OutputBuffer;
 }
示例#3
0
        protected override void InitializeLearningAlgorithms(BufferAllocator allocator, LearningLayerGroups learningLayerGroups, NNInitParameters initPars)
        {
            algorithms = new LearningAlgorithm[learningLayerGroups.Count];
            var biAlgos = new LinkedList<LearningAlgorithm>();
            var aeAlgos = new LinkedList<LearningAlgorithm>();

            int idx = 0;
            foreach (var group in learningLayerGroups)
            {
                var algo = CreateAlgorithmForRule(group.Rule);
                algo.InitializeAlgo(allocator, group.Rule, group.ConnectedLayers.ToArray(), (CPUNNInitParameters)initPars);
                algorithms[idx++] = algo;
                if (algo.Rule.IsBeforeIterationRule) biAlgos.AddLast(algo);
                if (algo.Rule.IsErrorBasedRule) aeAlgos.AddLast(algo);
            }

            beforeIterationAlgorithms = biAlgos.ToArray();
            errorBasedAlgorithms = aeAlgos.ToArray();
        }
示例#4
0
        protected override void Built(BufferAllocator allocator, ConnectedLayerGroups connectedLayerGroups, NNInitParameters initPars)
        {
            // Create buffer:
            valueBuffer = new float[allocator.Size];

            // RTLR:
            if ((StructuralElementFlags & NNStructuralElement.RTLRInformation) != 0)
            {
                pValProp = new PValuePropagator(connectedLayerGroups.IndexTable, forwardComputeGroups.SelectMany(g => g));
            }
        } 
 protected override void InitializeLearningAlgorithms(BufferAllocator allocator, Learning.LearningLayerGroups learningLayerGroups, NNInitParameters initPars)
 {
 }
        protected override void Built(BufferAllocator allocator, ConnectedLayerGroups connectedLayerGroups, NNInitParameters initPars)
        {
            // Create buffer:
            oclValueBuffer = oclContext.CreateBuffer<float>(allocator.Size, ComputeMemoryFlags.ReadWrite);

            // Fill with zeros: 
            // TODO: Add this stuff to and OpenCLUtils class or sumthin
            int size = 1000;
            int remain = allocator.Size % size;
            float[] zeros = new float[size];

            if (remain != 0) oclQueue.Write(oclValueBuffer, zeros, 0, remain, false);
            for (int i = remain; i < allocator.Size; i += size)
            {
                oclQueue.Write(oclValueBuffer, zeros, i, size, false);
            }

            oclQueue.ComputeCommandQueue.Finish();
        }