Esempio n. 1
0
 internal BetaSimilarity(Unit beta, SimilarityMeasure similarity)
 {
     _beta      = beta;
     Similarity = similarity;
     //Ensuring that beta will be positive
     _b = Math.Exp(_beta.Value);
     BetaSimilarityMeasure = new Unit(_b * Similarity.Similarity.Value);
 }
Esempio n. 2
0
 internal BetaSimilarity(Unit beta, SimilarityMeasure similarity)
 {
     _beta = beta;
     Similarity = similarity;
     //Ensuring that beta will be positive
     _b = Math.Exp(_beta.Value);
     BetaSimilarityMeasure = new Unit(_b * Similarity.Similarity.Value);
 }
Esempio n. 3
0
        internal MemoryState Process(Head[] heads)
        {
            int headCount = heads.Length;
            int memoryColumnsN = _memory.CellCountN;

            ReadData[] newReadDatas = new ReadData[headCount];
            HeadSetting[] newHeadSettings = new HeadSetting[headCount];
            for (int i = 0; i < headCount; i++)
            {
                Head head = heads[i];
                BetaSimilarity[] similarities = new BetaSimilarity[_memory.CellCountN];

                for (int j = 0; j < memoryColumnsN; j++)
                {
                    Unit[] memoryColumn = _memory.Data[j];
                    SimilarityMeasure similarity = new SimilarityMeasure(new CosineSimilarityFunction(), head.KeyVector, memoryColumn);
                    similarities[j] = new BetaSimilarity(head.Beta, similarity);
                }

                ContentAddressing ca = new ContentAddressing(similarities);
                GatedAddressing ga = new GatedAddressing(head.Gate, ca, _headSettings[i]);
                ShiftedAddressing sa = new ShiftedAddressing(head.Shift, ga);

                newHeadSettings[i] = new HeadSetting(head.Gamma, sa);
                newReadDatas[i] = new ReadData(newHeadSettings[i], _memory);
            }

            NTMMemory newMemory = new NTMMemory(newHeadSettings, heads, _memory);

            return new MemoryState(newMemory, newHeadSettings, newReadDatas);
        }