Table of ContentsPreviousNextIndex

Put your logo here!


5 Debugging Your HTM Application

This chapter gives some introductory information on troubleshooting your HTM application.

For additional up-to-date troubleshooting information, see the Numenta website's Education section.

Topics

Making Sure The Data Are Valid

When the results don't make sense, check first whether the data you're using are fed in appropriately and picked up by the HTM Network as expected. A number of things can go wrong with data preparation and data submission. Ask yourself these questions:

Some patterns are difficult to recognize by the human eye.

Per-Level Training: Troubleshooting Efficiently

If you train your HTM Network completely and then run inference, the results are not always satisfactory. One reason is that if nodes at one level in your hierarchy are not performing well, nodes at a higher levels can't perform well either because their input is difficult to process. Because of the dependency of each node on all lower levels, it makes sense to train and analyze your HTM Network one level at a time while working on performance improvements.

1. Train the bottom level of your HTM Network and stop the training before training higher levels.

2. Examine the bottom-level output. You can either use the Visualizer tool (see Using HTM Network Visualizer) or extract data structures from the nodes directly.

     categorySensor = runtimeNet.getElement("CategorySensor") 
     categorySensor = runtimeNet.CategorySensor 

3. See where potential problems lie, then change one or more parameters of the bottom-level nodes and repeat steps 1 and 2. For example:

4. Repeat this process level by level until you have trained and analyzed your HTM Network completely.

Experimenting With Parameters and Input Data

At times, certain settings - either learning node parameters or application-specific parameter settings - might make it impossible for your HTM Network to complete a run. An example is shown in Running the Example with Noisy Data, where the maxDistance parameter becomes too small for a run with noise and an error results. In addition, issues with your input data might make it impossible for the HTM Network to recognize the patterns.

Experiment With Key Parameters

Each node performs spatial learning (coincidence detection) and temporal learning (grouping).

See Affecting Learning Node Behavior With Node Parameters in Advanced NuPIC Programming for a discussion of each parameter.

If your files are set up appropriately, experimenting with key parameters is fairly straightforward. For example, in Bitworm, you can make changes to many of the parameters by editing RunOnce.py.

A second approach is to experiment with key parameters interactively. The Bitworm example includes a script, ParameterExploration.py that allows you to do so. Here is the core part of this script:

# Now instantiate the RuntimeNetwork 
net = CreateRuntimeNetwork("trained_bitworm.xml") 
 
# Get the level 1 node 
node = net.Level1 
 
# Run through all reasonable values for the topNeighbors parameter 
# and see the resulting number of groups. 
for t in range(1,10): 
   node.setParameter("topNeighbors",t) 
   node.execute("computeGroups") 
   print "With topNeighbors set to",t,"the number of groups = ", \ 
         node.getParameter("groupCount") 

When you run the script, you will see the network get trained and then see the effect of various topNeighbors values on the group structure of the Level1 node. Output is sent to stdout.

For example, you might find that a different topNeighbors value than the default value results in a cleaner group structure. With the default value, one of the groups has only one element, and it's not clear why that bitworm was not assigned to one of the groups. With topNeighbors value of 4, the Group 6 bitworm is assigned to the appropriate textured bitworms group.

Experiment With Input Data

There are a number of things to look for in your input data:

Consider Preprocessing Data

In some cases, preprocessing is necessary because your data don't match the sensor you're using. You might also consider preprocessing your raw data if you believe that the raw data are difficult for the HTM Network to process. For example, if you're working with an HTM vision system, consider running the images through an edge detector and feeding the edge output instead of the images themselves to the sensor. However, be careful: Whenever you replace the raw data with preprocessor output you choose, you run the risk of discarding useful correlations hidden in the raw data before the HTM Network even sees the data.

Experiment with Network Topology

As a rule, network topology, such as fan-in at each node and the number of levels in the hierarchy should be based on design decisions that stem from the hierarchical spatial and temporal correlations inherent in the problem. However, if you believe after experimentation that a different topology might yield better results, reconsider your design and try a different topology.

Adding levels and changing the number of nodes per level is easy with the helper functions.

Improving Recognition Accuracy

After your HTM Network has successfully completed a training run, you are ready to test your HTM Network's performance. Follow these steps:

Using HTM Network Visualizer

The Numenta Visualizer tool allows you to examine a trained HTM Network and see what the network has learned. Visualizer generates an HTML page for each node in the network. Each page displays the node's groups and coincidences as well as general statistics.

During development, it is usually best to train your network one level at a time, checking each level to make sure the nodes at that level have learned well before moving on. Training an entire network at once and then looking at end-to-end accuracy is not recommended, because it is difficult to determine exactly where a problem originates. If a certain level is not performing well, all higher levels are impacted because the outputs of one node are the inputs to its parent. You can use Visualizer to examine performance at one level before moving on to the next.

To illustrate the drawbacks of training the entire network at once, imagine that one of your bottom-level nodes is grouping all the patterns it sees into a single group. In this case, the nodes at the next level receive the exact same input no matter what data you feed to the hierarchy. The overall performance of your HTM Network is poor. It therefore makes sense to proceed as follows:

1. Run your training script, but stop after the Level 1 nodes have been trained.

2. Use Visualizer to examine the Level 1 nodes. If the nodes have poor coincidences and groups, change node parameters, and then train and look at the results again.

3. When you're satisfied with the bottom-level nodes, move on to successively higher levels of the hierarchy, making changes one level at a time.

Invoking Visualizer

Visualizer is installed as part of NuPIC and is located in the nupic.analysis package.

To invoke Visualizer

1. Start the Python interpreter.

   python -i 

2. Import the Visualizer module.

   from nupic.analysis import Visualizer 

3. Run the Visualizer on your trained network

   v = Visualizer(<your_network.xml>) 
   v.visualizeNetwork() 

where <your_network.xml> points to your trained HTM Network file

You can also run Visualizer automatically from another Python script by including the code from steps 2 and 3 above in your .py file. If you include a call to Visualizer at the end, the Visualizer HTML pages are generated automatically after training.

When you run Visualizer.visualizeNetwork(), Visualizer takes the following steps:

1. Starts a RuntimeNetwork with your trained HTM Network file.

2. Extracts data for each node in the HTM network.

3. Creates an HTML page for each node in the network, as well as a main page linking to all nodes.

If you wish to examine only a particular node, pass a node name or regular expression to Visualizer.visualizeNetwork(). For example, visualizeNetwork("level1.*") prints all nodes that begin with level1.

Visualizer deletes its temporary files when it is done.

Visualizer Output

The Visualizer output is organized as follows:

Supported Types of Data

Once your data is fed from the sensor into the bottom-level nodes of your HTM Network, the input to any node is a vector of floating-point numbers. The network does not necessarily know whether these vectors represent pixels of an image, letters of text, or something else entirely.

Based on the type of sensor in your network, Visualizer can determine how to turn each of the node's coincidences into its original form. At higher levels, the coincidences do not correspond to raw input, so Visualizer does not show them.

Interpreting Visualizer Output

Visualizer creates a folder named after your network, located in the same directory. Open the index.html page within it to see an overview page for the network. This overview page lists the total number of nodes in the network - including sensors, effectors, and other nodes that are not visualized - as well as the number of nodes visualized. For each visualized node, the main page contains a link to the node's page and a count of the number of coincidences and groups in that node. Here's a main page from the Waves example:

Figure 14 Visualizer Main Page (Waves Example)

Each node page displays the following information (See Figure 15):

Here's a node page from the Waves example:

Figure 15 Visualizer Node Page (Waves Example)

Using Visualizer to examine the nodes of your HTM Network allows you to see how well your network is performing. If you spot problems with nodes at a particular level, you can adjust the node's parameters to fix them. If you spot serious problems in the level 1 nodes - for example, the groups seem nonsensical - you might have to reexamine how you feed your data into the network.

Plotting and GUI Packages Bundled with NuPIC

In addition to Numenta Visualizer, a number of plotting and GUI packages are bundled with NuPIC:


Numenta
www.Numenta.com
Table of ContentsPreviousNextIndex