-
Notifications
You must be signed in to change notification settings - Fork 159
NAPI Quick Start Guide
Here you can find a more in depth explanation of the NAPI details, together with examples, and links to example code.
Let's get started!
Here's an example of the code it takes to get a full featured network up and running:
Parameters p = NetworkDemoHarness.getParameters();
p = p.union(NetworkDemoHarness.getNetworkDemoTestEncoderParams());
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(Anomaly.create())
.add(new TemporalMemory())
.add(new SpatialPooler())
.add(Sensor.create(FileSensor::create, SensorParams.create(
Keys::path, "", ResourceLocator.path("rec-center-hourly.csv"))))));
network.start();
...and that's it! The above network (while simple), contains a full complement of all NuPIC algorithms and computational devices.
Here we see how to connect multiple layers...
Parameters p = NetworkDemoHarness.getParameters();
p = p.union(NetworkDemoHarness.getNetworkDemoTestEncoderParams());
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(Anomaly.create())
.add(new TemporalMemory()))
.add(Network.createLayer("Layer 4", p)
.add(new SpatialPooler()))
.add(Network.createLayer("Layer 5", p)
.add(Sensor.create(FileSensor::create, SensorParams.create(
Keys::path, "", ResourceLocator.path("rec-center-hourly.csv")))))
.connect("Layer 2/3", "Layer 4")
.connect("Layer 4", "Layer 5"));
Here we see how to connect multiple layers and multiple regions...
Parameters p = NetworkDemoHarness.getParameters();
p = p.union(NetworkDemoHarness.getNetworkDemoTestEncoderParams());
// Shared connections example
Connections connections = new Connections();
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)
.using(connections) // Demonstrates Connections sharing between Layers in same Region
.add(Anomaly.create())
.add(new TemporalMemory()))
.add(Network.createLayer("Layer 4", p)
.using(connections) // Shared with different Layer above
.add(new SpatialPooler()))
.connect("Layer 2/3", "Layer 4"))
.add(Network.createRegion("Region 2")
.add(Network.createLayer("Layer 2/3", p)
.alterParameter(KEY.AUTO_CLASSIFY, Boolean.TRUE)
.add(Anomaly.create())
.add(new TemporalMemory())
.add(new SpatialPooler()))
.add(Network.createLayer("Layer 4", p)
.add(Sensor.create(FileSensor::create, SensorParams.create(
Keys::path, "", ResourceLocator.path("rec-center-hourly.csv")))))
.connect("Layer 2/3", "Layer 4"))
.connect("Region 1", "Region 2");
-
Algorithms should not be duplicated within a single Layer (i.e. Don't have 2 SpatialPoolers in the same layer for example).
-
Don't forget to connect Layers or Regions to each other as shown above. Adding a Layer and Region is not the same as connecting them; you must do both or there will be indeterminate behavior.
-
Sensors (FileSensor, URLSensor, ObservableSensor) must be added to a layer that is connected to the bottom of process flow.
- Introduction (Home)
- History & News Archives...
- Usability
- Architecture
- NAPI Quick Start Guide
- NAPI In Depth
- Saving Your Network: PersistenceAPI Serialization
- Roadmap
- Browse Java Docs
- Build Instructions
- Eclipse (Dev Setup)
- Anomaly Prediction
- Test Coverage Reports
- [Cortical.io Demos] (https://github.com/numenta/htm.java-examples/tree/master/src/main/java/org/numenta/nupic/examples/cortical_io)
- Hot Gym Demo
- Performance Benchmarks with jmh - blog
- BLOG: Join the "cogmission"