コード例 #1
0
        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);
        }
コード例 #2
0
        public void ShouldConvertBinaryToBipolarValues()
        {
            // when
            var bipolarSymbol = new BipolarSymbol(SymbolValuesWithZeroes());

            // then
            Assert.True(bipolarSymbol.ConvertToOneDimensionalArray().All(value => value == -1));
        }