Beispiel #1
0
        public override void UpdateSpeeds(double learningRate, double momentumCoefficient, double weightDecayCoefficient)
        {
            // Should include backpropagation to input in all member layers

            convolutionalLayer2.UpdateSpeeds(learningRate, momentumCoefficient, weightDecayCoefficient);
            convolutionalLayer2.BackPropagate();

            if (nonlinearityType == "ReLU")
            {
                nonlinearityReLU.BackPropagate();
            }
            else if (nonlinearityType == "ELU")
            {
                nonlinearityELU.BackPropagate();
            }

            convolutionalLayer1.UpdateSpeeds(learningRate, momentumCoefficient, weightDecayCoefficient);
            convolutionalLayer1.BackPropagate();
        }
        public void should_backpropagate_tensor_of_correct_size(int inputSize, int weightLength, int outputSize)
        {
            // Arrange
            _sut = (ConvolutionalLayer) new Net(inputSize, inputSize)
                   .ConvolutionTranspose(new[] { weightLength, weightLength })
                   .Layers[0];

            var trainingRun = new TrainingRun(1)
            {
                Input       = new float[inputSize, inputSize].ToMatrix(),
                Output      = _sut.FeedForwards(new float[inputSize, inputSize].ToMatrix()),
                OutputError = new float[outputSize, outputSize].ToMatrix()
            };

            // Act
            _sut.BackPropagate(trainingRun);

            // Assert
            Assert.That(trainingRun.InputError.Size, Is.EqualTo(trainingRun.Input.Size));
        }
        public void should_backpropagate_tensor_of_correct_kernel_size(int kernelSize)
        {
            // Arrange
            _sut = (ConvolutionalLayer) new Net(1, 1)
                   .ConvolutionTranspose(new[] { 5, 5 }, kernelSize)
                   .Layers[0];
            var input = new float[, ] {
                { 0 }
            }.ToMatrix();

            var trainingRun = new TrainingRun(1)
            {
                Input       = input,
                Output      = _sut.FeedForwards(input),
                OutputError = new Tensor(new Size(5, 5, kernelSize), new float[5 * 5 * kernelSize])
            };

            // Act
            _sut.BackPropagate(trainingRun);

            // Assert
            Assert.That(trainingRun.InputError.Size, Is.EqualTo(trainingRun.Input.Size));
        }