public void PerceptronThrowsErrorWhenWeightsAreAllZero() { _network.GetAllConnections().Enumerate(connection => connection.Properties.Weight = 0d); //Note: NullReferenceException means exception wasn't thrown var exception = Assert.Throws <InvalidOperationException>(() => _perceptron.CheckTopology()); exception.Message.Should().Be(Perceptron.WeightsAreAllZero); }
public async Task WeightInitializerInitializerWeightsOnAllConnections() { await _weightInitializer.PropagateWeightInitializationAsync(); var allConnections = _network.GetAllConnections(); _weightSetterMock.Verify(r => r.SetWeight(allConnections.ElementAt(0).Properties), Times.Once()); _weightSetterMock.Verify(r => r.SetWeight(allConnections.ElementAt(1).Properties), Times.Once()); _weightSetterMock.Verify(r => r.SetWeight(allConnections.ElementAt(2).Properties), Times.Once()); _weightSetterMock.Verify(r => r.SetWeight(allConnections.ElementAt(3).Properties), Times.Once()); _weightSetterMock.Verify(r => r.SetWeight(allConnections.ElementAt(4).Properties), Times.Once()); _weightSetterMock.Verify(r => r.SetWeight(allConnections.ElementAt(5).Properties), Times.Once()); _weightSetterMock.Verify(r => r.SetWeight(allConnections.ElementAt(6).Properties), Times.Once()); _weightSetterMock.Verify(r => r.SetWeight(allConnections.ElementAt(7).Properties), Times.Once()); }