Create and run HTM in programmatic manner


Sorry for my question, but where I can find examples in Python for creating HTM modle by coding , and not from parameters configuration file.
As programmer in soul I find the method of running the model from configuration file, little limited the explorer of the full framework.
For example I want to create my HTMpredic model by coding and not from configuration file, or create SWARM by coding and change my parameters by coding.


Hello and welcome to the community!
Don’t feel sorry for asking questions! It is how everyone learns, notifying what one don’t know and finding the solution.

The NuPIC API is divided up into 2 parts. The network API and the algorithm API. The network API is what you use with a configure file. On the other hand, the algorithm API allows one to create an instance of a layer, do anything with it. The algo API is what you want.

After installing, you might want to try the NuPIC API notebook.

If you want to work with C++ instead of Python. You can try my HTM library: tiny-htm. Which is easy to use and way faster than NuPIC. But may be a bit buggy for now and only has limited feature. NuPIC.cpp is a community fork of NuPIC’s core library the full set of features, but have a slightly annoying API (WIP fix).


Thanks!!! ,:smiley::smiley:


Hii @marty1885 ,
May you have any example for making swarming with the algorithm API , I am not found any example for that…


I just tune the parameters manfully. Typically I set

  • SP density = 0.08
  • Boosting = on
  • Boost factor = 1
  • TM perm inc = 0.04
  • TM perm dec = 0.045
  • TM active segment dec = 0.1*(TM perm inc)

And leave the rest as default and tune them if I need to.

While If I really need optimal parameters, I write my own grid-search code. (I use NuPIC.core so I don’t have access to swarming).


@MAK I think you will benefit from a review of the quick start. It is nice because it shows you how you can build out all 3 types of models (OPF, algorithms, and Network API) using the same model configuration, which is in a YAML file.