Giter VIP home page Giter VIP logo

htmpandavis's Introduction

HTMpandaVis

UPDATE 9/2020 - major change - using solely NetworkAPI of HTM.core - fully AUTOMATIC baking process ! UPDATE 6/2020 - major change - SQLITE3 instead of TCP sockets + Dash plots visualization in web browser !

See video tutorial or presentation video!

Screenshots for visualization of the 2D recognition project img1 img2 img2 dash visualization

This project aspires to create tool that helps visualize HTM systems in 3D by using opensource framework for 3D rendering https://www.panda3d.org/

It allows to see architecture of the system in 3D space, e.g. connection of several layers and inputs and to see input representation, activity of columns and even individual cells in each simulation step. User can observe vast scalable space by moving as "ghost" and interact with objects. It is supposed as tool for educational purpose or as an inspect tool.

I was inspired by following:

The visualization is application written purely in Python3.

How it works

  • Data for visualization are generated by so called "baking". This process generates sqlite3 database file, optionally folder with binary dump files.
  • User can open these data in HTMpandaVis and explore them

You can also browse SQLite3 dabase file (.db) directly with ordinary browser such as Sqlite Browser.

Baking

To bake your simulation, you must use htm.core networkAPI. Only difference is, that you need to import instead of from htm.bindings.engine_internal import Network this from pandaBaker.pandaNetwork import Network

That is all. PandaVis will generate automatically all data.

If you don't want to change imports and keep using panda, you can modify flag Network.bakePandaData = True/False

See baking readme.

Dash plots visualization

HTMpandaVis can be used also to record custom dataStreams with pandaBaker and then visualize it in web browser. Dash plotly library is used. These plots are interactive!. For creating layout arrangement, axis and plot labels, there are JSON layout configuration files. They are located in HTMpandaVis\dashVis\layouts. See hotgym example for more informations.

Usage with databaseRegion from htm.core networkAPI

Within htm.core, there is databaseRegion in networkAPI that allows to output scalar values into sqliteDatabase. Data can be then plot in the same way as above. See htm.core examples/napi_hello_database.

How to install on Linux

Python >3.6 is recommended. Also using one of the python environment managers is recommended, like Anaconda

Install htm.core (here building from source, see repo readme if you need other installation instructions)

sudo apt-get install cmake
git clone https://github.com/htm-community/htm.core.git
python setup.py install --user --force

Install prerequisities & clone pandaVis

sudo apt-get install python3-tk

git clone https://github.com/htm-community/HTMpandaVis.git

python -m pip install -r requirements.txt

 #this installs pandaBaker package for baking process
python setup.py install

Run example

There is NetworkAPI hotgym example in the htm.core repository.

All you have to do to bake it, is changing one line!

  1. For baking change : from htm.bindings.engine_internal import Network to from pandaBaker.pandaNetwork import Network

when you run the script, database and dump files will be created inside script folder in /bakedDatabase

  1. Run client - pandaVis tool
cd HTMpandaVis
python run.py

And choose run 3D explorer or "run both" if you want to run dash visualization also.

htmpandavis's People

Contributors

zbysekz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

htmpandavis's Issues

Exception: Missing command method: saveConnectionsToFile

Hi all,
First of thanks for the contribution of pandaVis, I would like to use the visualizations of the l2l4l6a experiment for a study project.

When running experiment1.py of the 2d object modelling project with the setting self.bakePandaData = True (line 72), I get the error
Exception: Missing command method: saveConnectionsToFile

full traceback
Traceback (most recent call last):
  File "/home/felix/labcourse2022/htm-2d-object-modeling/python/experiment1.py", line 380, in <module>
    experiment.learn(parameters, 0)
  File "/home/felix/labcourse2022/htm-2d-object-modeling/python/experiment1.py", line 270, in learn
    self.network.learn(streamForAllColumns)
  File "/home/felix/labcourse2022/htm-2d-object-modeling/venv/lib/python3.8/site-packages/htm.core-2.1.16-py3.8-linux-x86_64.egg/htm/advanced/support/logging_decorator.py", line 84, in _fn
    return fn(instance, *args, **kwargs)
  File "/home/felix/labcourse2022/htm-2d-object-modeling/python/l2l4l6Framework/l2_l4_l6_Network.py", line 157, in learn
    self.sendReset()
  File "/home/felix/labcourse2022/htm-2d-object-modeling/venv/lib/python3.8/site-packages/htm.core-2.1.16-py3.8-linux-x86_64.egg/htm/advanced/support/logging_decorator.py", line 84, in _fn
    return fn(instance, *args, **kwargs)
  File "/home/felix/labcourse2022/htm-2d-object-modeling/python/l2l4l6Framework/l2_l4_l6_Network.py", line 132, in sendReset
    self.network.run(1)
  File "/home/felix/labcourse2022/htm-2d-object-modeling/venv/lib/python3.8/site-packages/HTMpandaVis-0.1-py3.8.egg/pandaBaker/pandaNetwork.py", line 37, in run
  File "/home/felix/labcourse2022/htm-2d-object-modeling/venv/lib/python3.8/site-packages/HTMpandaVis-0.1-py3.8.egg/pandaBaker/pandaBaker.py", line 96, in StoreIteration
  File "/home/felix/labcourse2022/htm-2d-object-modeling/venv/lib/python3.8/site-packages/htm.core-2.1.16-py3.8-linux-x86_64.egg/htm/bindings/regions/PyRegion.py", line 354, in executeMethod
    raise Exception('Missing command method: ' + methodName)
Exception: Missing command method: saveConnectionsToFile

in the current htm.core repository the region py.GridCellLocationRegion doesn't implement the saveConnectionsToFile Method (executed here).

I assume implementing the method and saving the right connections will fix this problem and I will try changing the code in these classes to implement the method.
But as I'm not super familiar with all the htm.core bindings & stuff yet I was wondering if there is a workaround for that you (@Zbysekz) used for the visualization in your video

Best,
Felix

Readme suggestion for htm.core

Hi @Zbysekz , this looks really awesome! ๐Ÿ‘ Congratulations!
And thanks for bringing the project under the htm-community umbrella.

A few suggestions as I'm going to test this proj:

  • you could put the requirements (along with the minimal supported versions) to a requirements.txt file for easier install
  • would you like to make a PR to htm.core Readme with a section
##Related community work

Community projects for working with HTM. 

### Visualization
#### HTMPandaVis

and put your short description and a nice image here

?

Traceback (most recent call last): File "hotgym.py", line 340, in <module> main() File "hotgym.py", line 216, in main pdf = predictor.infer(count, tm.getActiveCells()) TypeError: infer(): incompatible function arguments. The following argument types are supported: 1. (self: htm.bindings.algorithms.Predictor, pattern: htm.bindings.sdr.SDR) -> Dict[int, List[float]] Invoked with: <htm.bindings.algorithms.Predictor object at 0x7f2eabb52e30>, 0, <htm.bindings.sdr.SDR object at 0x7f2eabb52ea0>

Hi , one problem on run application.my environment is ubuntu18 and Annaconda ,i try run it ,but has problem. please help .Thanks
`Traceback (most recent call last):
File "hotgym.py", line 340, in
main()
File "hotgym.py", line 216, in main
pdf = predictor.infer(count, tm.getActiveCells())
TypeError: infer(): incompatible function arguments. The following argument types are supported:
1. (self: htm.bindings.algorithms.Predictor, pattern: htm.bindings.sdr.SDR) -> Dict[int, List[float]]

Invoked with: <htm.bindings.algorithms.Predictor object at 0x7f2eabb52e30>, 0, <htm.bindings.sdr.SDR object at 0x7f2eabb52ea0>
`

Error in running PandaVis

Extract from Numenta Discussion Forum
Hi, getting the following error when trying to run the hotgym example with pandavis (runs fine without pandavis). Can you please advise?

File โ€œ/Users/soubhikchatterjee/.local/lib/python3.7/site-packages/HTMpandaVis-0.1-py3.7.egg/pandaBaker/pandaBaker.pyโ€, line 56, in PrepareDatabase
self.db.Insert(tableName, regionName,regionInstance[0], json.dumps(regionInstance[1].getParameters()))

RuntimeError: Attribute getParameters not found.

Zbysekz
HTM Wizard
4d
Hello, please this kind of problems post as issues in github repository.
Anyway, it seems that you have pretty old pandaVis version (0.1) package, but current is 1.0.

I have installed Pandavis from this repository. Please advise how to get the current version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.