public void AlternativeTwoToManyAdditionNeuronInLayerUsingBuilders(decimal val1, decimal val2, int neuronCount) { // Arrange var outputLayer = new OutputLayerBuilder<decimal> { NumberOfNeurons = 1 }.Build(); var fixedWrappedOutputBuilder = new FixedValueBuilder<IEnumerable<IObserver<decimal>>> { Value = outputLayer }; var hiddenLayerBuilder = new WrappingHiddenLayerBuilder<decimal, decimal> { FunctionSource = new ByDefaultConstructorBuilder<DecimalSumFunction>(), NextLayer = fixedWrappedOutputBuilder }; var inputLayerBuilder = new SimpleHiddenLayerBuilder<decimal, decimal> { NumberOfNeurons = 2, NextLayerBuilder = hiddenLayerBuilder, FunctionSource = new ByDefaultConstructorBuilder<DecimalSumFunction>() }; var sut = inputLayerBuilder.Build().ToList(); // Act sut[0].OnNext(new decimal[] { val1 }); sut[1].OnNext(new decimal[] { val2 }); // Assert var result = fixedWrappedOutputBuilder.Value.Cast<ValueStoringNeuron<decimal>>().Single().LastValue; result.Should().Be(val1 + val2); }
public void AlternativeSingleAdditionNeuronInLayerUsingBuilders(decimal val1, decimal val2) { // Arrange var outputLayer = new OutputLayerBuilder<decimal> { NumberOfNeurons = 1 }.Build(); var fixedWrappedOutputBuilder = new FixedValueBuilder<IEnumerable<IObserver<decimal>>> { Value = outputLayer }; var layerBuilder = new WrappingHiddenLayerBuilder<decimal, decimal> { FunctionSource = new ByDefaultConstructorBuilder<DecimalSumFunction>(), NextLayer = fixedWrappedOutputBuilder }; var sut = new CompositeObserver<IEnumerable<decimal>>(layerBuilder.Build()); // Act sut.OnNext(new decimal[] { val1, val2 }); // Assert var result = fixedWrappedOutputBuilder.Value.Cast<ValueStoringNeuron<decimal>>().Single().LastValue; result.Should().Be(val1 + val2); }