HTMCLA
A C++ implementation of Numenta's Hierarchical Temporal Memory (HTM) Cortical Learning Algorithm (CLA). Uses Qt for user interface.
Install / Use
/learn @MichaelFerrier/HTMCLAREADME
=========================================================================================== HTMCLA
A C++ implementation of Numenta's Hierarchical Temporal Memory Cortical Learning Algorithm By Michael Ferrier, 2013.
This C++ implementation is based on Numenta's CLA white paper: https://www.groksolutions.com/htm-overview/education/HTM_CorticalLearningAlgorithms.pdf
It builds on the OpenHTM C# implementation: https://sourceforge.net/p/openhtm/
A couple of demonstration videos are online here: http://www.youtube.com/watch?v=IXg_XIm5kqk http://www.youtube.com/watch?v=YeBC9eew3Lg
=========================================================================================== Build Instructions
HTMCLA depends on the Qt user interface library. The latest version can be downloaded here: http://qt-project.org/downloads
To get Qt working and building with Visual Studio 2012 on Windows 7 64-bit, I had to follow these steps:
- Install QT from http://qt-project.org/downloads. Use "Qt 5.0.2 for Windows 64-bit (VS 2012, 500 MB)".
- Install QT's Visual Studio add in, from http://qt-project.org/downloads. Use "Visual Studio Add-in 1.2.1 for Qt5".
- Open VS, open QT5 menu, go to QT Options. Add the msvc2012_64 directory under the QT installation (the directory with 'bin' in it).
- In VS, under Build >> Configuration Manager, make sure Platform is set to x64.
- Under Project >> Properties >> Configuration Properties >> Linker >> Advanced, make sure Target Machine is also set to X64.
- Under QT5 >> QT Project Settings, set Version to msvc2012_64.
- Create and attempt to build project. May find that you need to rename lib files being used (in the QT install) to have a '5' before the dot at the end of their filenames.
I can't speak for how Qt 5 should be configured on other setups, but I find there's a lot of help on the web.
Once you have Qt5 integrated into your environment, you should be able to create a project in an environment of your choice that incorporates QT 5 and each of this project's .cpp and .h files. If you're using Visual Studio 2012, you should be able to use the htm.sln file.
=========================================================================================== Using HTMCLA
File Menu
Load Network: Load a .xml file specifying the architecture of a CLA network. This file would be created in a text editor. The HTMCLA package comes with several test network files in the "data" subdirectory.
Load Data: You can load the segment and synapse data into a network, so that you can load up the state of that network after training. This is especially useful for complex learning tasks where training takes a long time. You can only load a data file into the same network from which it was saved (although the network parameters may be diffrent from what they were when the data was saved). Data is saved in a .clad file (CLA data).
Save Data: After training a network, you can save out its segment and synapse data so that you can load it directly into the same network on a later run, without having to redo the training. It is saved out as a .clad (CLA data) file.
Exit: Exit the program.
View Menu
Update while running: If this is checked, the UI will be updated after each time step when running the network. This slows down execution significantly, but may be useful to watch progress in some cases.
Mouse Menu
Toggles mouse function between "Select" and "Drag". In select mode, whatever is under the mouse is selected when the left button is clicked. When in drag mode, the view can be repositioned by being dragged. This function remains buggy.
Network Panel
Displays the filename of the loaded network.
The || (Pause), > (Single Step), and >> (Continuous Run) buttons are used to control execution of the network.
The current time step is displayed, as well as the "Stop at:" field. If a number is entered here, continuous execution will cease at that given time step.
Selected Panel
By left clicking on a cell or column in one of the views, that cell or column is selected. Information about the selected cell, column and region is displayed in this panel. If a cell is selected and if it has distal segments, a list of those segments is displayed at the bottom. If the views are displaying connections (synapses), then all of the selected column's proximal synapses will be shown, and all of the selected cell's distal synapses will be shown. To display just the distal synapses on one segment, select that segment by clicking on its line in the list. To deselect the segment and return to displaying all synapses on all distal segments, click the "Display all segments" button.
The table of segments is currently quite slow to update, so displaying the segments on a cell with many distal segments can cause the program to pause for a few seconds.
The Views
On the left side of the UI are two views of the network. Each one can display one region or input space. If you'd like, they can both display the same region or input space. To select what it is that a view displays, select the name of the region or input space from the view's "Show:" menu.
A view's "Options" menu contains several options for what information is displayed in the view:
View Activity: Displays in the view what cells are active (orange), and what cells are predicted (yellow for one-step prediction, pink for >1 step prediction).
View Top-Down Reconstruction: Displays a reconstruction of what is active in the region or input space, based on what is active in the region(s) that it outputs to. Synapses are traced backwards from active cells in the output region(s), to determine what cells in this region (or input space) would lead to those activations.
View Prediction: Displays a reconstruction of what is predicted to be active in the region or input space during the next time step, based on what cells are 1-step predictive in the region(s) that it outputs to. Synapses are traced backwards from 1-step predictive cells in the output region(s), to determine what cells in this region (or input space) would lead to those activations.
View Boost: When this is on, each column is colored to show its relative boost value. The brightest red columns have the highest boost values, while grey columns are not boosted at all.
View Connection In: When this is on, synapses from cells that input to the selected cell and/or column are displayed in the view. Red synapses are not connected; green synapses are connected. The brighter the color, the further the synapse's value from ConnectedPerm (in either direction). Zoom in on the area to view the permanence values of the syanpses. A selected column's proximal synapses are shown in it's region's input region(s) or input space(s). A cell's distal synapses are shown in the cell's same region.
View Connections In: This feature is not yet implemented. Eventually it will display the synapses that output from the selected cell to other cells.
View Marked Cells: Cells can be marked so as to, for example, compare what cells are active at one time step with what cells are active at a later time step. If this option is selected, then a black dot will be shown over each marked cell.
Mark Active and Predicted Cells: All cells that are currently active or in predictive state in the view are marked. Note that the marks will only show if "View Marked Cells" is selected.
Mark Predicted Cells: All cells that are in predictive state are marked.
Mark Learning Cells: All cells that are learning cells (a subset of active cells) are marked.
The magnifying class icons and the slider between them are used to zoom in and out of the view. At closer zoom levels, more informaton is displayed, such as the coordinates of columns, the permanence values of synapses, and an "L" over learning cells.
The scrollbars may be used to reposition what part of the view is visible.
The divider between the two views can be slid from side to side to changes the sizes of the views. The divider can also be slid all the way to the outer edge, to hide a view. It can then be grabbed back from the outer edge to re-show that view.
=========================================================================================== Network Files
Network architecture is specified in a .xml file that can be created in a text editor. HTMCLA comes with several example network files, located in the "data" subdirectory. The network file specifies all parameters for each region and input space in the network, as well as any input patterns that an input space will use.
The network file format is based loosely on the OpenHTM network file format, with a number of changes. Most of the features of a network file are self explanatory by looking at the examples. Here are a few notes:
The synapse parameters can be specified separately for proximal and distal synapses, using the <ProximalSynapseParams> and <DistalSynapseParams> blocks. When used outside of any Region block (ie. when not nested), these parameters are used as the default for all proximal or distal synapses throughout all Regions. In addition to specifying network-wide default synapse parameters, you can specify synapse parameters specific to a Region by using the <ProximalSynapseParams> and <DistalSynapseParams> blocks nested within the <Region> block.
A network is composed of <Inpu
Related Skills
YC-Killer
2.7kA library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star ⭐️ this repository and use the link in the readme to join our open source AI research team.
groundhog
399Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).
last30days-skill
18.8kAI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
sec-edgar-agentkit
10AI agent toolkit for accessing and analyzing SEC EDGAR filing data. Build intelligent agents with LangChain, MCP-use, Gradio, Dify, and smolagents to analyze financial statements, insider trading, and company filings.
