Exemplo n.º 1
0
        public override void SetupOutput()
        {
            // TODO: should include ConnectTo() , SetupOutput(), OutputNeurons.SetupBuffers(miniBatchSize), and SetWorkGroups() of member layers

            //______________________________________________________________________________________________________
            // Setup first convolutional layer

            convolutionalLayer1.InputNeurons = this.InputNeurons; // assignment is by reference!
            convolutionalLayer1.NInputUnits  = this.NInputUnits;
            convolutionalLayer1.InputWidth   = this.InputWidth;
            convolutionalLayer1.InputHeight  = this.InputHeight;
            convolutionalLayer1.InputDepth   = this.InputDepth;

            convolutionalLayer1.SetupOutput();
            convolutionalLayer1.OutputNeurons.SetupBuffers(convolutionalLayer1.InputNeurons.MiniBatchSize);
            convolutionalLayer1.SetWorkGroups();

            //______________________________________________________________________________________________________
            // Setup nonlinearity
            if (nonlinearityType == "ReLU")
            {
                nonlinearityReLU.ConnectTo(convolutionalLayer1);
                nonlinearityReLU.SetupOutput();
                nonlinearityReLU.OutputNeurons.SetupBuffers(nonlinearityReLU.InputNeurons.MiniBatchSize);
                nonlinearityReLU.SetWorkGroups();

                convolutionalLayer2.ConnectTo(nonlinearityReLU);
            }
            else if (nonlinearityType == "ELU")
            {
                nonlinearityELU.ConnectTo(convolutionalLayer1);
                nonlinearityELU.SetupOutput();
                nonlinearityELU.OutputNeurons.SetupBuffers(nonlinearityELU.InputNeurons.MiniBatchSize);
                nonlinearityELU.SetWorkGroups();

                convolutionalLayer2.ConnectTo(nonlinearityELU);
            }
            //______________________________________________________________________________________________________
            // Setup second convolutional layer

            convolutionalLayer2.SetupOutput();
            //convolutionalLayer2.OutputNeurons.SetupBuffers(convolutionalLayer2.InputNeurons.MiniBatchSize);
            convolutionalLayer2.SetWorkGroups();

            //______________________________________________________________________________________________________
            // Setup output neurons
            this.outputWidth  = convolutionalLayer2.OutputWidth;
            this.outputHeight = convolutionalLayer2.OutputHeight;
            this.outputDepth  = convolutionalLayer2.OutputDepth;

            this.nOutputUnits  = outputDepth * outputWidth * outputHeight;
            this.outputNeurons = convolutionalLayer2.OutputNeurons;
        }