public void Evaluate_WithPassthroughAF_WithSingleHiddenLayer_WithSingleInputAndOutput_ReturnsInputTimesWeight() { FullyConnectedNN nn = new FullyConnectedNN(new[] { 1, 1, 1 }, AF.Passthrough); float[] output = nn.Evaluate(new[] { 0.8f }, new[] { 0.8f, 0.8f }); AssertFloat.AreAlmostEqual(0.512f, output[0]); }
public void EvaluateNeuron_WithPassthroughAF_WithMultipleInputs_ReturnsCorrectValue() { FullyConnectedNN nn = new FullyConnectedNN(new[] { 2, 1 }, AF.Passthrough); AssertFloat.AreAlmostEqual(0.0f, nn.EvaluateNeuron(new[] { 0.0f, 0.0f }, 1, new[] { 1.0f, 1.0f }, 0)); AssertFloat.AreAlmostEqual(0.8f, nn.EvaluateNeuron(new[] { 0.3f, 0.5f }, 1, new[] { 1.0f, 1.0f }, 0)); AssertFloat.AreAlmostEqual(0.3f, nn.EvaluateNeuron(new[] { 0.5f, -0.4f }, 1, new[] { 1.0f, 0.5f }, 0)); }
public void EvaluateNeuron_WithPassthroughAF_WithSingleInput_ReturnsInputValueTimesWeight() { FullyConnectedNN nn = new FullyConnectedNN(new[] { 1, 1 }, AF.Passthrough); AssertFloat.AreAlmostEqual(-1.0f, nn.EvaluateNeuron(new[] { -1.0f }, 1, new[] { 1.0f }, 0)); AssertFloat.AreAlmostEqual(0.35f, nn.EvaluateNeuron(new[] { 0.35f }, 1, new[] { 1.0f }, 0)); AssertFloat.AreAlmostEqual(0.5f, nn.EvaluateNeuron(new[] { 1.0f }, 1, new[] { 0.5f }, 0)); }
public void Evaluate_WithPassthroughAF_WithMultipleHiddenLayers_WithMultipleInputAndOutput_ReturnsCorrect() { FullyConnectedNN nn = new FullyConnectedNN(new[] { 2, 2, 2 }, AF.Passthrough); float[] output = nn.Evaluate(new[] { 1.0f, -1.0f }, new[] { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f }); AssertFloat.AreAlmostEqual(-0.11f, output[0]); AssertFloat.AreAlmostEqual(-0.15f, output[1]); }
public void EvaluateLayer_WithPassthroughAF_WithMultipleInputs_ReturnsCorrectValues() { FullyConnectedNN nn = new FullyConnectedNN(new[] { 2, 2 }, AF.Passthrough); int offsetWeight = 0; float[] output = nn.EvaluateLayer(new[] { 1.0f, -1.0f }, 1, new[] { 0.9f, 1.0f, 1.0f, 0.5f }, ref offsetWeight); AssertFloat.AreAlmostEqual(-0.1f, output[0]); AssertFloat.AreAlmostEqual(0.5f, output[1]); }
public void EvaluateLayer_WithPassthroughAF_WithSingleInput_ReturnsInputValueTimesWeights() { FullyConnectedNN nn = new FullyConnectedNN(new[] { 1, 2 }, AF.Passthrough); int offsetWeight = 0; float[] output = nn.EvaluateLayer(new[] { 1.0f }, 1, new[] { 0.3f, -1.0f }, ref offsetWeight); AssertFloat.AreAlmostEqual(0.3f, output[0]); AssertFloat.AreAlmostEqual(-1.0f, output[1]); offsetWeight = 0; output = nn.EvaluateLayer(new[] { -0.5f }, 1, new[] { 0.5f, -1.0f }, ref offsetWeight); AssertFloat.AreAlmostEqual(-0.25f, output[0]); AssertFloat.AreAlmostEqual(0.5f, output[1]); }