Phase 1
The first phase calculates the activeState for each cell that is in a winning column. For those columns, the code further selects one cell per column as the learning cell (learnState). The logic is as follows: if the bottom-up input was predicted by any cell (i.e. its predictiveState output was 1 due to a sequence segment), then those cells become active (lines 23-27). If that segment became active from cells chosen with learnState on, this cell is selected as the learning cell (lines 28-30). If the bottom-up input was not predicted, then all cells in the become active (lines 32-34). In addition, the best matching cell is chosen as the learning cell (lines 36-41) and a new segment is added to that cell.
18. for c in activeColumns(t) 19. 20. buPredicted = false 21. lcChosen = false 22. for i = 0 to cellsPerColumn - 1 23. if predictiveState(c, i, t-1) == true then 24. s = getActiveSegment(c, i, t-1, activeState) 25. if s.sequenceSegment == true then 26. buPredicted = true 27. activeState(c, i, t) = 1 28. if segmentActive(s, t-1, learnState) then 29. lcChosen = true 30. learnState(c, i, t) = 1 31. 32. if buPredicted == false then 33. for i = 0 to cellsPerColumn - 1 34. activeState(c, i, t) = 1 35. 36. if lcChosen == false then 37. I,s = getBestMatchingCell(c, t-1) 38. learnState(c, i, t) = 1 39. sUpdate = getSegmentActiveSynapses (c, i, s, t-1, true) 40. sUpdate.sequenceSegment = true 41. segmentUpdateList.add(sUpdate)
|