Join GitHub today
NAPI In Depth Component Overview
[Hint:] Drill down into each topic (by clicking the header) for more info.
NOTE: Not yet fully complete - all items will have links to more in-depth detail soon - stay tuned!
This is a brief summary of components within a network together with a brief discussion of their usage. Let's list them to get an understanding of what the api is doing underneath.
Intra - Network
- Network - Contains all constructs and is the "typical" interface through which a network is used. Networks can contain multiple Regions which in turn (as stated above), can contain multiple Layers.
- Region - Also created by a factory method of Network, and is the container of Layers.
- Layer - Created by a factory method of Network, this is a network specific construct which is the container for all algorithms. Layers are the structure or allegory for the physical layers found in the neocortex. Layers contain the columns and cells discretely used by its configured algorithms (meaning two layers must be specifically configured to share columns, cells or Connections objects - which is possible). Multiple Layers may be connected together within a given Region.
Intra - Layer
- Anomaly - The anomaly computer. Can be used as shown above or can be further customized by creation outside of the fluent network declaration.
- CLAClassifier - (Not seen below) ...at least not explicitly.
Network network = Network.create("Network API Demo", p) .add(Network.createRegion("Region 1") .add(Network.createLayer("Layer 2/3", p) **.alterParameter(KEY.AUTO_CLASSIFY, Boolean.TRUE)** .add(new SpatialPooler())
There are two things of note here. The first is that only a Boolean is declared here to indicate that a classifier is desired at this location; and secondly there is this method:
This method statement which is specifically injected here, tells the framework to use a copy of the Parameters object within this Layer. Normally, Parameters are inherited from the parent container (i.e. Region or Network), but when used, this method allows local altering of a given parameter without affecting the Parameters object used throughout the network.
- TemporalMemory - Optionally added to a given network's Layer to provide temporal/sequence learning. The TemporalMemory is automatically configured during Layer initialization using the specified Parameters object.
- SpatialPooler - Optionally added to a given network's Layer to provide spatial learning. The SpatialPooler is automatically configured during Layer initialization using the specified Parameters object.
Intra - Sensor
- Sensor - Contains 3 flavors: FileSensor, URLSensor, ObservableSensor. These specify different ways to connect to data and submit input into a network.
- MultiEncoder - Is created automagically by all Sensors using the encoder parameters inserted into the Parameters object and header lines found in the given file (or in the case of ObservableSensor which is used for manual/programmatic data submission, headers can be inserted by hand). A MultiEncoder is a specialized encoder which is a container for other encoders. In this case, there are two child encoders created; a Scalar encoder for the "consumption" field (double); and a DateEncoder to parse and encode the date column of the CSV input file.
- ResourceLocator - Used to locate resources on the classpath such as files or even files in Jars! It provides a virtual resource link to the Sensor. This is very useful, but does have room for improvement/enhancement (hint) :-)
- Input File Format - Here is an example input file header: (All headers must have 3 lines - column names; data types; and control flags)
HTM.java follows the NuPIC Input File Format seen at the link above - except - for a couple of flags (see HTM.java SensorFlags). These are the "L" flag which specifies a "learning" column, and the "B" flag which is automatically inserted into the file when no flag is specified for a column (which you don't have to be concerned with really). The "T" flag while encouraged, does not mean that the encoders cycle through known datetime formats.
For the time being, date formats are specified in the Parameters object like this:
Parameters p = ... p.put(KEY.DATEFIELD_PATTERN.getFieldName(), "MM/dd/YY HH:mm");
Where all Date formats follow the normal Java conventions seen here: from Joda Time Library
For example formats, see the DateEncoder class
- Parameters - Settings containers used as arguments to the Network.create() methods. The "harness" classes help to keep the code concise by offloading parameter configuration to another general class. These may or may not be configured to your liking, and are used for demonstration purposes here.
Example used in the Quick Start Guide
Parameters p = NetworkDemoHarness.getParameters(); p = p.union(NetworkDemoHarness.getNetworkDemoTestEncoderParams());