public void ShouldRecogniseInversedSymbolWithNoises() { // given var hopfieldNetwork = new HopfieldNetwork(); var symbolsToLearn = new List <BipolarSymbol> { SymbolFactory.CreateBipolarFromDigit(0), SymbolFactory.CreateBipolarFromDigit(1), SymbolFactory.CreateBipolarFromDigit(2) }; hopfieldNetwork.Learn(symbolsToLearn); // when bool symbolIsRecognised = hopfieldNetwork.TryRecognise(IversedNumberOneWithNoises()); // then Assert.Equal(1, hopfieldNetwork.IterationsCountOfRecognising); Assert.True(symbolIsRecognised); BipolarSymbol expectedRecognisedSymbol = SymbolFactory.CreateBipolarFromDigit(1); expectedRecognisedSymbol.Inverse(); Assert.Equal(expectedRecognisedSymbol.ConvertToOneDimensionalArray(), hopfieldNetwork.SymbolsOut); }
public void ShouldConvertBinaryToBipolarValues() { // when var bipolarSymbol = new BipolarSymbol(SymbolValuesWithZeroes()); // then Assert.True(bipolarSymbol.ConvertToOneDimensionalArray().All(value => value == -1)); }
public void ShouldDoesNotChangeCorrectValues() { // given const int rowWithNegativeValue = 0; const int rowWithPositiveValue = 1; // when var bipolarSymbol = new BipolarSymbol(SymbolValuesWithVariedValues(rowWithNegativeValue, rowWithPositiveValue)); // then for (var column = 0; column < SymbolValues.ColumnSize; column++) { Assert.Equal(-1, bipolarSymbol.Values[rowWithNegativeValue, column]); Assert.Equal(1, bipolarSymbol.Values[rowWithPositiveValue, column]); } }
public void ShouldInverseValues() { // given const int rowWithOriginallyNegativeValue = 0; const int rowWithOriginallyPositiveValue = 1; var bipolarSymbol = new BipolarSymbol(SymbolValuesWithVariedValues(rowWithOriginallyNegativeValue, rowWithOriginallyPositiveValue)); // when bipolarSymbol.Inverse(); // then for (var column = 0; column < SymbolValues.ColumnSize; column++) { Assert.Equal(1, bipolarSymbol.Values[rowWithOriginallyNegativeValue, column]); Assert.Equal(-1, bipolarSymbol.Values[rowWithOriginallyPositiveValue, column]); } }