Represents an HTM network.
More...
#include <Network.hpp>
|
void | save (const std::string &name) |
| Save the network to a network bundle (extension .nta ). More...
|
|
|
Region * | addRegion (const std::string &name, const std::string &nodeType, const std::string &nodeParams) |
| Create a new region in a network. More...
|
|
Region * | addRegionFromBundle (const std::string &name, const std::string &nodeType, const Dimensions &dimensions, const std::string &bundlePath, const std::string &label) |
| Create a new region from saved state. More...
|
|
Region * | addRegionFromProto (const std::string &name, RegionProto::Reader &proto) |
| Create a new region from saved Cap'n Proto state. More...
|
|
void | removeRegion (const std::string &name) |
| Removes an existing region from the network. More...
|
|
void | link (const std::string &srcName, const std::string &destName, const std::string &linkType, const std::string &linkParams, const std::string &srcOutput="", const std::string &destInput="") |
| Create a link and add it to the network. More...
|
|
void | removeLink (const std::string &srcName, const std::string &destName, const std::string &srcOutputName="", const std::string &destInputName="") |
| Removes a link. More...
|
|
|
void | enableProfiling () |
| Start profiling for all regions of this network.
|
|
void | disableProfiling () |
| Stop profiling for all regions of this network.
|
|
void | resetProfiling () |
| Reset profiling timers for all regions of this network.
|
|
void | write (std::ostream &stream) const |
|
void | read (std::istream &stream) |
|
void | write (NetworkProto::Builder &proto) const |
|
void | read (NetworkProto::Reader &proto) |
|
Represents an HTM network.
A network is a collection of regions.
Definition at line 55 of file Network.hpp.
typedef void(* nupic::Network::runCallbackFunction)(Network *, UInt64 iteration, void *) |
The type of run callback function.
You can attach a callback function to a network, and the callback function is called after every iteration of run().
To attach a callback, just get a reference to the callback collection with getCallbacks() , and add a callback.
Definition at line 347 of file Network.hpp.
nupic::Network::Network |
( |
| ) |
|
nupic::Network::Network |
( |
const std::string & |
path | ) |
|
Create a Network by loading previously saved bundle, and register it to NuPIC.
- Parameters
-
path | The path to the previously saved bundle file, currently only support files with .nta extension. |
- Note
- Creating a Network will auto-initialize NuPIC.
nupic::Network::~Network |
( |
| ) |
|
Destructor.
Destruct the network and unregister it from NuPIC:
- Uninitialize all regions
- Remove all links
- Delete the regions themselves
- Todo:
- Should we document the tear down steps above?
Region* nupic::Network::addRegion |
( |
const std::string & |
name, |
|
|
const std::string & |
nodeType, |
|
|
const std::string & |
nodeParams |
|
) |
| |
Create a new region in a network.
- Parameters
-
name | Name of the region, Must be unique in the network |
nodeType | Type of node in the region, e.g. "FDRNode" |
nodeParams | A JSON-encoded string specifying writable params |
- Returns
- A pointer to the newly created Region
Region* nupic::Network::addRegionFromBundle |
( |
const std::string & |
name, |
|
|
const std::string & |
nodeType, |
|
|
const Dimensions & |
dimensions, |
|
|
const std::string & |
bundlePath, |
|
|
const std::string & |
label |
|
) |
| |
Create a new region from saved state.
- Parameters
-
name | Name of the region, Must be unique in the network |
nodeType | Type of node in the region, e.g. "FDRNode" |
dimensions | Dimensions of the region |
bundlePath | The path to the bundle |
label | The label of the bundle |
- Todo:
- label is the prefix of filename of the saved bundle, should this be documented?
- Returns
- A pointer to the newly created Region
Region* nupic::Network::addRegionFromProto |
( |
const std::string & |
name, |
|
|
RegionProto::Reader & |
proto |
|
) |
| |
Create a new region from saved Cap'n Proto state.
- Parameters
-
name | Name of the region, Must be unique in the network |
proto | The capnp proto reader |
- Returns
- A pointer to the newly created Region
Get reference to callback Collection.
- Returns
- Reference to callback Collection
UInt32 nupic::Network::getMaxEnabledPhase |
( |
| ) |
const |
Get the maximum enabled phase for this network.
- Returns
- Maximum enabled phase for this network
UInt32 nupic::Network::getMaxPhase |
( |
| ) |
const |
Get maximum phase for regions in this network.
If no regions, then max = 0.
- Returns
- Maximum phase
UInt32 nupic::Network::getMinEnabledPhase |
( |
| ) |
const |
Get the minimum enabled phase for this network.
- Returns
- Minimum enabled phase for this network
UInt32 nupic::Network::getMinPhase |
( |
| ) |
const |
Get minimum phase for regions in this network.
If no regions, then min = 0.
- Returns
- Minimum phase
std::set<UInt32> nupic::Network::getPhases |
( |
const std::string & |
name | ) |
const |
Get phases for a region.
- Parameters
-
- Returns
- Set of phases for the region
const Collection<Region*>& nupic::Network::getRegions |
( |
| ) |
const |
Get all regions.
- Returns
- A Collection of Region objects in the network
void nupic::Network::initialize |
( |
| ) |
|
Initialize all elements of a network so that it can run.
- Note
- This can be called after the Network structure has been set and before Network.run(). However, if you don't call it, Network.run() will call it for you. Also sets up various memory buffers etc. once the Network structure has been finalized.
void nupic::Network::link |
( |
const std::string & |
srcName, |
|
|
const std::string & |
destName, |
|
|
const std::string & |
linkType, |
|
|
const std::string & |
linkParams, |
|
|
const std::string & |
srcOutput = "" , |
|
|
const std::string & |
destInput = "" |
|
) |
| |
Create a link and add it to the network.
- Parameters
-
srcName | Name of the source region |
destName | Name of the destination region |
linkType | Type of the link |
linkParams | Parameters of the link |
srcOutput | Name of the source output |
destInput | Name of the destination input |
void nupic::Network::removeLink |
( |
const std::string & |
srcName, |
|
|
const std::string & |
destName, |
|
|
const std::string & |
srcOutputName = "" , |
|
|
const std::string & |
destInputName = "" |
|
) |
| |
Removes a link.
- Parameters
-
srcName | Name of the source region |
destName | Name of the destination region |
srcOutputName | Name of the source output |
destInputName | Name of the destination input |
void nupic::Network::removeRegion |
( |
const std::string & |
name | ) |
|
Removes an existing region from the network.
- Parameters
-
void nupic::Network::run |
( |
int |
n | ) |
|
Run the network for the given number of iterations of compute for each Region in the correct order.
For each iteration, Region.compute() is called.
- Parameters
-
void nupic::Network::save |
( |
const std::string & |
name | ) |
|
Save the network to a network bundle (extension .nta
).
- Parameters
-
void nupic::Network::setMaxEnabledPhase |
( |
UInt32 |
minPhase | ) |
|
Set the maximum enabled phase for this network.
- Parameters
-
minPhase | Maximum enabled phase |
void nupic::Network::setMinEnabledPhase |
( |
UInt32 |
minPhase | ) |
|
Set the minimum enabled phase for this network.
- Parameters
-
minPhase | Minimum enabled phase |
void nupic::Network::setPhases |
( |
const std::string & |
name, |
|
|
std::set< UInt32 > & |
phases |
|
) |
| |
Set phases for a region.
- Parameters
-
name | Name of the region |
phases | A tuple of phases (must be positive integers) |
The documentation for this class was generated from the following file: