| | |
- __builtin__.object
-
- nupic.bindings.network.NetworkElement
-
- nupic.bindings.network.Network
- nupic.bindings.network.Node
- nupic.bindings.network.Region
- nupic.bindings.network.NodeIOGroup
-
- nupic.bindings.network.NodeInputGroup
- nupic.bindings.network.NodeOutputGroup
- nupic.bindings.network.NodeSetStream
- nupic.bindings.network.RunPolicy
-
- nupic.bindings.network.ForAllVectors
- nupic.bindings.network.ForEachSequence
- nupic.bindings.network.RandomBlocks
- nupic.bindings.network.RandomVectors
- nupic.bindings.network.SimpleCompute
- nupic.bindings.network.TrainPhase
- nupic.bindings.network.TrainPhase
- nupic.bindings.network.UntilException
- nupic.bindings.network.RuntimeElement
-
- nupic.bindings.network.RuntimeNetwork
- nupic.bindings.network.RuntimeNode
- nupic.bindings.network.RuntimeRegion
- nupic.bindings.network.RuntimeResponse
- nupic.bindings.network.Session
- nupic.bindings.network.SessionConfiguration
- nupic.bindings.network.SessionLogConfig
- nupic.bindings.network.SessionServerDistribution
- nupic.bindings.network.SessionUpdateFrequency
-
- nupic.bindings.network.EveryTime
- nupic.bindings.network.MinDelay
- nupic.bindings.network.NumComputes
- nupic.bindings.network.ToolsPluginManagerPtr
- nupic.network.Parameterized.Parameterized
-
- nupic.network.DataInterface.DataInterface
-
- nupic.network.simpledatainterface.MultiDataInterface
- nupic.network.simpledatainterface.SimpleDataInterface
- nupic.network.NetInterface.NetInterface
-
- nupic.network.simplehtm.SimpleHTM
- nupic.bindings.network.APRThreadNetworkIO(__builtin__.object)
-
- nupic.bindings.network.ThreadedNetworkXMLReader
- nupic.bindings.network.ThreadedNetworkXMLWriter
- nupic.bindings.network.ThreadedSessionLoader
- nupic.bindings.network.Parameter(__builtin__.object)
-
- nupic.bindings.network.ParameterGroup
- nupic.bindings.network.ParameterGroup
- nupic.bindings.network.WrappedSharedSessionPtr(__builtin__.object)
-
- nupic.bindings.network.SharedSessionPtr
- nupic.network.Parameterized.Parameter
class DataInterface(nupic.network.Parameterized.Parameterized) |
| |
This class represents a data set, which may be automatically generated.
It is intended to be subclassed to match any particular sort of data set.
The subclasses may store data in files (which are easy to load into the Runtime),
or generate it on the fly.
Important parameters that every object of this type has:
prefix: the prefix that all files will have tacked on the front
files: the files that are in the data set. This set can be manipulated
directly or by addDataFiles(). One can get a list of the files
with prefix added by calling getPrefixedDataFiles(). Any more
complicated data-file operations should be handled directly by the
sub-class.
Child classes should override the following functions:
createData: creates data
visualizeData: displays the data in some meaningful way. You don't have to override this, but it's helpful if you want to see your data.
getData: gets a plottable set of data |
| |
- Method resolution order:
- DataInterface
- nupic.network.Parameterized.Parameterized
- __builtin__.object
Methods defined here:
- __init__(self)
- addDataFile(self, file)
- Add a data file which can be accessed starting at the prefix.
This is essentially just a way to add to the 'files' parameter.
- addDataFiles(self, files)
- Add a number of data files which will be accessed starting at prefix.
This is essentially just a way to add to the 'files' parameter.
- cleanup(self)
- Clean up data which has been created. This method is called when the
test being run no longer has any need for the DataInterface object's data.
Child classes should override this method especially for DataInterface
objects that create large data sets because otherwise you risk having
large quantities of data left over, clogging your disks.
- createData(self)
- Create data, any files of which should be placed at self['prefix'].
Child classes should override this method if they need to create any
data.
- getData(self)
- Return data which has been created, in a form conducive to plotting.
This method is useful when trying to plot the data along with something
else, such as accuracy. The format is:
[[[x,y,z],[x,y,z], ...], #row 1
[[x,y,z],[x,y,z], ...], #row 2
...]
Child classes should override this method to let other people plot this
data easily. It is recommended to use this method in your own
visualizeData method.
- getPrefixedDataFiles(self)
- Get the data file names, including the prefix. The list of files used
for this function contained in the parameter 'files'.
- visualizeData(self, filename=None)
- Visualize data which has been created. Therefore, createData should be
run first. Child classes should override this method in order to give a
hook to visualize data. We used to provide functions called 'easyPlot2D'
and 'easyPlot3D', but now that we have switched to using matplotlib,
plotting is so easy that there's no point in providing those functions.
Methods inherited from nupic.network.Parameterized.Parameterized:
- __getitem__(self, name)
- Overload the [] operator to get parameter values.
- __repr__(self)
- __setitem__(self, name, value)
- Overload the [] operator to set parameter values.
- __str__(self)
- Adding a __str__ method will make str(parameterized) work.
- addParam(self, name, **attributes)
- Create a parameter with the given name and attributes.
The attributes must contain one of type, value, or default, since the
parameter must somehow determine its type. The calling syntax is the same
as Parameter.__init__.
- calculateStateFromParams()
- Override this to calculate derived state from parameters.
This is important because when saving, it is preferable to save only
parameters. Thus, upon loading (or upon changing parameters) this derived
information must be regenerated.
- getParam(self, name)
- Get the named parameter; this is NOT for getting the parameter's value.
- getValue(self, name)
- Get the value of the named parameter.
- getoptOptions(self)
- Get the getopt options for my parameters.
- hasParam(self, name)
- iterate(self, name=None, parameter=None, **iterParams)
- Iterate over the named parameter in numSteps even-sized steps from its
minimum to maximum value.
The resulting iterator iterates over copies of this Parameterized object
with different parameter values set. This makes it possible to use
recursively. It should be mentioned that all data is copied by reference,
except for the named parameter, which is duplicated in every copy.
Either the parameter should be named, or a parameter should be given to
iterate over.
Parameters
----------
name: The name of the parameter.
parameter: The parameter to iterate over.
iterParams: Extra parameters will be passed to the Parameter's
iterate method. Ordinarily, no other parameters need be passed.
- loadGetoptOptions(self, options)
- Read the parameters for my parameters from the options array while
ignoring unrelated options.
See the getopt library for more on getopt.
- loadParams(self, filename)
- Load parameters from a file.
- paramNames(self)
- Get all the names of my parameters
- printGetoptMessage(self)
- Print a list of options
- savable(self, *args, **keywordArgs)
- Create a savable copy of this Parameterized object containing just its
parameters and none of its other member data.
This is handy for saving Parameterized objects without all their messy
member data, such as generated data points or learned matrices. Saving
self, rather than savable(), can produce copious data. Of course, you
can override this to save additional data if you like.
Note: This function takes arguments and keyword arguments to pass
to the constructor of your class BUT nothing external should ever
use them. They are here to make it easy to override this method.
Suppose your class takes two non-optional parameters (param1 and
keywordParam) to its constructor. You can then easily override
Parameterized.savable() with the following code:
def savable(self):
return Parameterized.savable(self, param1, keywordParam)
- saveParams(self, filename)
- Save parameters to a file.
- setParam(self, name, param)
- Set the named parameter; this is NOT for setting the parameter's value.
- setValue(self, name, value)
- Set the value of the named parameter.
- valuesEqual(self, other, ignoredParams=[])
- Test whether the two Parameterized objects have the same parameters.
Note that this does _NOT_ check any other member data!
You should have all the important information as parameters.
Parameters
----------
other: Another Parameterized object to compare with
ignoredParams: Parameters to ignore when comparing values (e.g. one
might want to neglect the 'prefix' parameter).
Data descriptors inherited from nupic.network.Parameterized.Parameterized:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class ForAllVectors(RunPolicy) |
| |
C++ includes:
RunPolicy.hpp |
| |
- Method resolution order:
- ForAllVectors
- RunPolicy
- __builtin__.object
Methods defined here:
- __init__(self, *args, **kwargs)
- __init__(self, elements=std::vector<std::string >(1, std::string()),
blockSize=1.0f) -> ForAllVectors
htmtools::ForAllVectors::ForAllVectors(const std::vector< std::string
> &elements=std::vector< std::string >(1, std::string()), float
blockSize=1.0f)
- __repr__ = _swig_repr(self)
Data descriptors defined here:
- thisown
- The membership flag
Data and other attributes defined here:
- __swig_destroy__ = <built-in function delete_ForAllVectors>
Methods inherited from RunPolicy:
- clone(*args, **kwargs)
- clone(self) -> RunPolicy
virtual RunPolicy*
htmtools::RunPolicy::clone() const =0
- notifyProgress(*args, **kwargs)
- notifyProgress(self, sequencesDone, sequencesRemaining, iterationsDone,
iterationsRemaining)
void
RunPolicy::notifyProgress(int sequencesDone, int sequencesRemaining,
int iterationsDone, int iterationsRemaining) const
- registerListener(*args, **kwargs)
- registerListener(self, p, key)
void
RunPolicy::registerListener(IRunPolicyListener *p, long long key)
Registers the listener with a client-data key.
- registerPyListener(*args, **kwargs)
- registerPyListener(self, p) -> long long
long
long RunPolicy::registerPyListener(PyObject *p)
- run(*args, **kwargs)
- run(self, base, selection, exclusion, selectedElements=std::vector<htmtools::RuntimeElement >())
virtual void
htmtools::RunPolicy::run(RuntimeElement &base, const std::vector<
std::string > &selection, const std::vector< std::string > &exclusion,
const std::vector< htmtools::RuntimeElement >
&selectedElements=std::vector< htmtools::RuntimeElement >()) const =0
- unregisterListener(*args, **kwargs)
- unregisterListener(self, p, key)
void
RunPolicy::unregisterListener(IRunPolicyListener *p, long long key)
Removes exactly one matching listener registration.
- unregisterPyListener(*args, **kwargs)
- unregisterPyListener(self, key)
void RunPolicy::unregisterPyListener(long long key)
Data descriptors inherited from RunPolicy:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- listeners_
|
class ForEachSequence(RunPolicy) |
| |
C++ includes:
RunPolicy.hpp |
| |
- Method resolution order:
- ForEachSequence
- RunPolicy
- __builtin__.object
Methods defined here:
- __init__(self, *args, **kwargs)
- __init__(self, elements=std::vector<std::string >(1, std::string()),
blockSize=1.0f) -> ForEachSequence
htmtools::ForEachSequence::ForEachSequence(const std::vector<
std::string > &elements=std::vector< std::string >(1, std::string()),
float blockSize=1.0f)
- __repr__ = _swig_repr(self)
Data descriptors defined here:
- thisown
- The membership flag
Data and other attributes defined here:
- __swig_destroy__ = <built-in function delete_ForEachSequence>
Methods inherited from RunPolicy:
- clone(*args, **kwargs)
- clone(self) -> RunPolicy
virtual RunPolicy*
htmtools::RunPolicy::clone() const =0
- notifyProgress(*args, **kwargs)
- notifyProgress(self, sequencesDone, sequencesRemaining, iterationsDone,
iterationsRemaining)
void
RunPolicy::notifyProgress(int sequencesDone, int sequencesRemaining,
int iterationsDone, int iterationsRemaining) const
- registerListener(*args, **kwargs)
- registerListener(self, p, key)
void
RunPolicy::registerListener(IRunPolicyListener *p, long long key)
Registers the listener with a client-data key.
- registerPyListener(*args, **kwargs)
- registerPyListener(self, p) -> long long
long
long RunPolicy::registerPyListener(PyObject *p)
- run(*args, **kwargs)
- run(self, base, selection, exclusion, selectedElements=std::vector<htmtools::RuntimeElement >())
virtual void
htmtools::RunPolicy::run(RuntimeElement &base, const std::vector<
std::string > &selection, const std::vector< std::string > &exclusion,
const std::vector< htmtools::RuntimeElement >
&selectedElements=std::vector< htmtools::RuntimeElement >()) const =0
- unregisterListener(*args, **kwargs)
- unregisterListener(self, p, key)
void
RunPolicy::unregisterListener(IRunPolicyListener *p, long long key)
Removes exactly one matching listener registration.
- unregisterPyListener(*args, **kwargs)
- unregisterPyListener(self, key)
void RunPolicy::unregisterPyListener(long long key)
Data descriptors inherited from RunPolicy:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- listeners_
|
class MinDelay(SessionUpdateFrequency) |
| |
A SessionUpdateFrequency that specifies updates should be triggered on
the first call to compute in the runtime engine, and then on each
compute that occurs more than 'n' seconds after the last trigger.
C++ includes: SessionUpdate.hpp |
| |
- Method resolution order:
- MinDelay
- SessionUpdateFrequency
- __builtin__.object
Methods defined here:
- __init__(self, *args, **kwargs)
- __init__(self, n) -> MinDelay
nta::MinDelay::MinDelay(double n)
- __repr__ = _swig_repr(self)
Data descriptors defined here:
- thisown
- The membership flag
Data and other attributes defined here:
- __swig_destroy__ = <built-in function delete_MinDelay>
Methods inherited from SessionUpdateFrequency:
- __eq__(*args, **kwargs)
- __eq__(self, o) -> bool
- __lt__(*args, **kwargs)
- __lt__(self, f) -> bool
- __ne__(*args, **kwargs)
- __ne__(self, o) -> bool
Data descriptors inherited from SessionUpdateFrequency:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- n_
- type_
|
class MultiDataInterface(nupic.network.DataInterface.DataInterface) |
| | |
- Method resolution order:
- MultiDataInterface
- nupic.network.DataInterface.DataInterface
- nupic.network.Parameterized.Parameterized
- __builtin__.object
Methods defined here:
- __init__(self, dataFilenames, sensorDims=None, categoryFilenames=None, numCat=None, header=False)
- getPrefixedDataFiles(self)
Methods inherited from nupic.network.DataInterface.DataInterface:
- addDataFile(self, file)
- Add a data file which can be accessed starting at the prefix.
This is essentially just a way to add to the 'files' parameter.
- addDataFiles(self, files)
- Add a number of data files which will be accessed starting at prefix.
This is essentially just a way to add to the 'files' parameter.
- cleanup(self)
- Clean up data which has been created. This method is called when the
test being run no longer has any need for the DataInterface object's data.
Child classes should override this method especially for DataInterface
objects that create large data sets because otherwise you risk having
large quantities of data left over, clogging your disks.
- createData(self)
- Create data, any files of which should be placed at self['prefix'].
Child classes should override this method if they need to create any
data.
- getData(self)
- Return data which has been created, in a form conducive to plotting.
This method is useful when trying to plot the data along with something
else, such as accuracy. The format is:
[[[x,y,z],[x,y,z], ...], #row 1
[[x,y,z],[x,y,z], ...], #row 2
...]
Child classes should override this method to let other people plot this
data easily. It is recommended to use this method in your own
visualizeData method.
- visualizeData(self, filename=None)
- Visualize data which has been created. Therefore, createData should be
run first. Child classes should override this method in order to give a
hook to visualize data. We used to provide functions called 'easyPlot2D'
and 'easyPlot3D', but now that we have switched to using matplotlib,
plotting is so easy that there's no point in providing those functions.
Methods inherited from nupic.network.Parameterized.Parameterized:
- __getitem__(self, name)
- Overload the [] operator to get parameter values.
- __repr__(self)
- __setitem__(self, name, value)
- Overload the [] operator to set parameter values.
- __str__(self)
- Adding a __str__ method will make str(parameterized) work.
- addParam(self, name, **attributes)
- Create a parameter with the given name and attributes.
The attributes must contain one of type, value, or default, since the
parameter must somehow determine its type. The calling syntax is the same
as Parameter.__init__.
- calculateStateFromParams()
- Override this to calculate derived state from parameters.
This is important because when saving, it is preferable to save only
parameters. Thus, upon loading (or upon changing parameters) this derived
information must be regenerated.
- getParam(self, name)
- Get the named parameter; this is NOT for getting the parameter's value.
- getValue(self, name)
- Get the value of the named parameter.
- getoptOptions(self)
- Get the getopt options for my parameters.
- hasParam(self, name)
- iterate(self, name=None, parameter=None, **iterParams)
- Iterate over the named parameter in numSteps even-sized steps from its
minimum to maximum value.
The resulting iterator iterates over copies of this Parameterized object
with different parameter values set. This makes it possible to use
recursively. It should be mentioned that all data is copied by reference,
except for the named parameter, which is duplicated in every copy.
Either the parameter should be named, or a parameter should be given to
iterate over.
Parameters
----------
name: The name of the parameter.
parameter: The parameter to iterate over.
iterParams: Extra parameters will be passed to the Parameter's
iterate method. Ordinarily, no other parameters need be passed.
- loadGetoptOptions(self, options)
- Read the parameters for my parameters from the options array while
ignoring unrelated options.
See the getopt library for more on getopt.
- loadParams(self, filename)
- Load parameters from a file.
- paramNames(self)
- Get all the names of my parameters
- printGetoptMessage(self)
- Print a list of options
- savable(self, *args, **keywordArgs)
- Create a savable copy of this Parameterized object containing just its
parameters and none of its other member data.
This is handy for saving Parameterized objects without all their messy
member data, such as generated data points or learned matrices. Saving
self, rather than savable(), can produce copious data. Of course, you
can override this to save additional data if you like.
Note: This function takes arguments and keyword arguments to pass
to the constructor of your class BUT nothing external should ever
use them. They are here to make it easy to override this method.
Suppose your class takes two non-optional parameters (param1 and
keywordParam) to its constructor. You can then easily override
Parameterized.savable() with the following code:
def savable(self):
return Parameterized.savable(self, param1, keywordParam)
- saveParams(self, filename)
- Save parameters to a file.
- setParam(self, name, param)
- Set the named parameter; this is NOT for setting the parameter's value.
- setValue(self, name, value)
- Set the value of the named parameter.
- valuesEqual(self, other, ignoredParams=[])
- Test whether the two Parameterized objects have the same parameters.
Note that this does _NOT_ check any other member data!
You should have all the important information as parameters.
Parameters
----------
other: Another Parameterized object to compare with
ignoredParams: Parameters to ignore when comparing values (e.g. one
might want to neglect the 'prefix' parameter).
Data descriptors inherited from nupic.network.Parameterized.Parameterized:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class NetInterface(nupic.network.Parameterized.Parameterized) |
| |
This class represents attributes of a Numenta HTM network. It stores
parameters describing the network and has functions for training and testing
that network.
Child classes should override the following functions:
createNetwork: creates an HTM network
train: trains the network
test: evaluates the network |
| |
- Method resolution order:
- NetInterface
- nupic.network.Parameterized.Parameterized
- __builtin__.object
Methods defined here:
- __init__(self)
- cleanup(self)
- Clean up any files that won't be needed once this NetInterface is gone. This
method should be overridden by subclasses. The removed files should
include untrained network files, trained network files, session
directories, and so on. This method is only needed if you want to clean up
this data afterward. Personally, I find that this data can really make
messy directories and clog the disk, so it helps to remove it.
Caution: This method may be called more than once (with different sets of
unique IDs), so it shouldn't die if some files don't exist.
Suggestion: try using 'shutil.rmtree' to remove directories.
- createNetwork(self, data)
- A method to create a network based on the current parameters and data
parameters.
Child classes should override this method. A suggestion: The resulting
network should be written to prefix+'net.xml'.
Parameters
----------
data: DataInterface the network will be configured to handle.
- postTestUpdate(self, testResult)
- This method is called after the network has been tested. See the
description of NetInterface.test() for why; the summary is that network.test()
is run in a child process, so if it modifies data structures these changes
are lost. Instead, make changes by returning them from network.test() and
then applying the changes here in postTestUpdate().
- postTrainUpdate(self, trainResult)
- This method is called after the network has been trained. See the
description of NetInterface.train() for why; the summary is that network.train()
is run in a child process, so if it modifies data structures these changes
are lost. Instead, make changes by returning them from network.train() and
then applying the changes here in postTrainUpdate().
- test(self, data, uniqueID, np=1, hosts=None)
- Test the model on the data (which should be a DataInterface object).
Child classes should override this method. A suggestion: this should load
the network from prefix+'trained-net.xml'. Of course, train() should be
run before test(). It should return a dictionary of whatever parameters we
want to test, such as the accuracy. Note that this dictionary will be
pickled (for saving it and passing it from process to process), so
returning unpicklable objects may cause problems.
Note: The 'uniqueID' parameter should be inserted into any filenames
created while running the test so that tests don't overwrite each other.
You can ignore the 'uniqueID' parameter ONLY if you never plan to run
parallel tests. If you run parallel tests, then ignoring the suffix
parameter runs the risk of having different tests run in the same working
directory, thus overwriting each other and doing unpredictable things.
WARNING: When using NetExplorer's built-in parallelization, this function
will be run from a forked child process. As a result, no Python data will
be saved! When this function is running, it will only have access to
COPIES of all Python objects. Data written to disk (e.g. the trained
network.xml file) will be saved, and the value returned from this function
will be used to store the test results and also sent to the real NetInterface's
'postTestUpdate' method. So, if you have some changes to the NetInterface that
you must make during training (other than the data that is written to
disk), you must return the changes from this function and then apply them
in postTestUpdate.
In other words, write this function as though it was being called with
copies of variables like this:
network.postTestUpdate(copy.deepcopy(network).test(...))
Returns a dictionary mapping the names of test results to their values.
Parameters
----------
data: The training data.
uniqueID: A unique identifier string to keep different tests from
overwriting each other.
np: The number of node processors to run.
hosts: A list of hostnames containing the machines on which to run
your test. This is needed in order to take advantage of
NetExplorer's built in parallelization.
- train(self, data, np=1, hosts=None)
- A method to train on the data (which should be a DataInterface object).
Child classes should override this method. A suggestion: this should load
the network at prefix+'net.xml' and the data from the data parameter and
write a network at prefix+'trained-net.xml'.
WARNING: When using NetExplorer's built-in parallelization, this function
will be run from a forked child process. As a result, no Python data will
be saved! When this function is running, it will only have access to
COPIES of all Python objects. Data written to disk (e.g. the trained
network.xml file) will be saved, and the value returned from this function
will be pickled and sent to the real NetInterface's 'postTrainUpdate'
method. So, if you have some changes to the NetInterface that you must
make during training (other than the data that is written to disk), you
must return the changes from this function and then apply them in
postTrainUpdate. Also, because this function's return value will be
pickled, you should only return picklable objects; returning anything else
may cause problems.
In other words, write this function as though it was being called like this:
network.postTrainUpdate(copy.deepcopy(network).train(...))
Any return value will be pickled and sent to
NetInterface.postTrainUpdate(value).
Parameters
----------
np: The number of node processors to run.
hosts: A list of computer hostnames to run the training on.
This should be used by Session when training. This is needed
in order to take advantage of NetExplorer's built in
parallelization.
Methods inherited from nupic.network.Parameterized.Parameterized:
- __getitem__(self, name)
- Overload the [] operator to get parameter values.
- __repr__(self)
- __setitem__(self, name, value)
- Overload the [] operator to set parameter values.
- __str__(self)
- Adding a __str__ method will make str(parameterized) work.
- addParam(self, name, **attributes)
- Create a parameter with the given name and attributes.
The attributes must contain one of type, value, or default, since the
parameter must somehow determine its type. The calling syntax is the same
as Parameter.__init__.
- calculateStateFromParams()
- Override this to calculate derived state from parameters.
This is important because when saving, it is preferable to save only
parameters. Thus, upon loading (or upon changing parameters) this derived
information must be regenerated.
- getParam(self, name)
- Get the named parameter; this is NOT for getting the parameter's value.
- getValue(self, name)
- Get the value of the named parameter.
- getoptOptions(self)
- Get the getopt options for my parameters.
- hasParam(self, name)
- iterate(self, name=None, parameter=None, **iterParams)
- Iterate over the named parameter in numSteps even-sized steps from its
minimum to maximum value.
The resulting iterator iterates over copies of this Parameterized object
with different parameter values set. This makes it possible to use
recursively. It should be mentioned that all data is copied by reference,
except for the named parameter, which is duplicated in every copy.
Either the parameter should be named, or a parameter should be given to
iterate over.
Parameters
----------
name: The name of the parameter.
parameter: The parameter to iterate over.
iterParams: Extra parameters will be passed to the Parameter's
iterate method. Ordinarily, no other parameters need be passed.
- loadGetoptOptions(self, options)
- Read the parameters for my parameters from the options array while
ignoring unrelated options.
See the getopt library for more on getopt.
- loadParams(self, filename)
- Load parameters from a file.
- paramNames(self)
- Get all the names of my parameters
- printGetoptMessage(self)
- Print a list of options
- savable(self, *args, **keywordArgs)
- Create a savable copy of this Parameterized object containing just its
parameters and none of its other member data.
This is handy for saving Parameterized objects without all their messy
member data, such as generated data points or learned matrices. Saving
self, rather than savable(), can produce copious data. Of course, you
can override this to save additional data if you like.
Note: This function takes arguments and keyword arguments to pass
to the constructor of your class BUT nothing external should ever
use them. They are here to make it easy to override this method.
Suppose your class takes two non-optional parameters (param1 and
keywordParam) to its constructor. You can then easily override
Parameterized.savable() with the following code:
def savable(self):
return Parameterized.savable(self, param1, keywordParam)
- saveParams(self, filename)
- Save parameters to a file.
- setParam(self, name, param)
- Set the named parameter; this is NOT for setting the parameter's value.
- setValue(self, name, value)
- Set the value of the named parameter.
- valuesEqual(self, other, ignoredParams=[])
- Test whether the two Parameterized objects have the same parameters.
Note that this does _NOT_ check any other member data!
You should have all the important information as parameters.
Parameters
----------
other: Another Parameterized object to compare with
ignoredParams: Parameters to ignore when comparing values (e.g. one
might want to neglect the 'prefix' parameter).
Data descriptors inherited from nupic.network.Parameterized.Parameterized:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Network(NetworkElement) |
| |
A Network stores and allows you to manipulate the structure of an HTM
network, its elements and the connectivity between them.
A RuntimeNetwork is needed to actually run the network.
Network supports common operations important for working with HTM
Network structures:
Add NetworkElements to a Network with add().
Access individual elements contained in a Network as an attribute in
Python or with getElement().
Link named elements contained in a Network with LinkPolicies using
link().
Iterate over all contained elements with Python iterator idioms (the
elements attribute) or with getElementIterator().
Save a Network to an HTM Network file with save().
Determine the number of contained NetworkElements with
getElementCount().
Network is also a NetworkElement. Network inherits and implements all
of the NetworkElement interface. It is possible (though uncommon) to
add a Network instance as a contained element of another Network, or
to use a Network instance as a template for a Region.
Network stores a static schema describing the network, its nodes and
links. It cannot be used to interact dynamically with the individual
nodes of an HTM Network running in the Numenta Runtime Engine. Use
createRuntimeNetwork() to get a network representation that is
connected to the runtime engine via a Session, and that can interact
with nodes in the runtime engine.
Networks can be created empty (the default constructor) or loaded from
a file (pass the file name to the Network constructor).
C++ includes: Network.hpp |
| |
- Method resolution order:
- Network
- NetworkElement
- __builtin__.object
Methods defined here:
- __getattr__(self, name)
- __init__(self, arg1=None, arg2=None, arg3=None, filename=None, plugins=None, format=None, network=None, elements=[], name=None)
- __init__(self, filename=filename, plugins=plugins, format="nta")
__init__(self, elements=[])
__init__(self, network)
Network constructor: creates a new reference to a Network object.
There are several important variants of the Network constructor.
Network(network=filename, plugins=None, format="nta")
Loads a Network object stored in a file stored at 'filename'.
If 'plugins' is specified, this will be the PluginManager
used to interpret node state. Otherwise, the default PluginManager
will be used.
The file format is specified with 'format'. Only 'nta' is supported
in the current version of NuPIC.
Example:
myNetwork = Network("trained.xml")
Network(network):
Copy constructor. Creates a new reference to the Network
specified in the first argument. The first argument must be of
type NetworkElement.
Example:
myElement = myNetwork.getElement("level1[0]")
myNetwork = Network(myElement.getRoot())
Network():
Default constructor. Create a new empty Network object and acts as a
reference to that Network.
Example:
myNetwork = Network()
Network(elements=[]):
Creates a new empty Network containing no sub-elements, then
reads elements from the list of elements and adds them.
In the list of elements, each element must be specified as a
tuple of string name and element, or as a Link.
Example:
myNetwork = Network([
("sensor", Node()),
("level1", Region()),
Link(type="SensorLink", source="sensor", destination="level1"),
])
Notes on loading HTM Network XML files:
Because HTM Network XML file format is not in one-to-one
correspondence with some of the NetworkElement features, the
constructed Network instance will not exactly represent the HTM
network stored in the file, and will not exactly match the
NetworkElement that was originally used to write the HTM Network XML
file to disk.
After loading a Network from an HTM Network file, supported actions
include:
- Structural exploration of the Network.
- Adding new Nodes, Regions, Networks and LinkPolicies.
- Removing existing elements and links.
- Writing the modified Network to a file with writeXML().
Unsupported features include:
- Node::getParameter():
Node parameters are not stored, only node serialized state is stored
in the Network. getParameter() will throw exceptions when called on
nodes loaded from a file.
- Modification of existing Region template elements:
Every element contained by a Region is considered customized
after loading from a file. The custom elements will be
unaffected by modifications to the Region template.
- __repr__(*args, **kwargs)
- __repr__(self) -> string
std::string
htmtools::Network::__repr__() const
- add(*args)
- add(self, element)
add(self, record) -> int
add(self, name, element)
void
htmtools::Network::add(const std::string &name, const NetworkElement
&element)
Add a named referece to a NetworkElement to the Network.
The name must be unique among all NetworkElements that have been added
to this Network.
NetworkElement names can only be made of a restricted set of
characters. Legal characters include: [a-z]|[A-Z][0-9][_] Illegal sub-
strings include: ".", " ", "\"", "'", "&", "<", ">",
"[", "]", "\\", "/". The name cannot be empty.
Parameters:
-----------
name: (string) The unique name to assign the NetworkElement when
storing.
element: ( NetworkElement) The element to add a reference to inside
the Network.
- addElement(self, name, element)
- addElement(name, element) -> NetworkElement
Add a copy of a NetworkElement to the Network with the specified name.
The name must be unique among all NetworkElements that have been added
to this Network. No containment checks are necessary to prevent
cyclical references because the NetworkElement passed in and all
elements it contains are copied.
NetworkElement names can only be made of a restricted set of
characters. Legal characters include: [a-z]|[A-Z][0-9][_] Illegal sub-
strings include: ".", " ", """, "'", "&", "<", ">",
"[", "]", "\", "/". The name cannot be empty.
Parameters:
-----------
name: (string)
The unique name to assign the NetworkElement when storing.
element: (NetworkElement)
The element of which a copy whill be stored.
- addLink(*args)
- addLink(self, record, check=True) -> int
addLink(self, atIndex, record, check=True) -> int
int
Network::addLink(int atIndex, const SharedLinkPtr &record, bool
check=true)
- clearLinks(*args, **kwargs)
- clearLinks(self)
void
Network::clearLinks()
Remove all links stored by this container.
- createRuntimeNetwork(self, bundlePath=None, files=None, config=None, session=None, numNodeProcessors=0, scheduler='')
- Creates and returns a RuntimeNetwork given a Network and information
for configurating a Session.
Parameters:
-----------
bundlePath: (string) The optional filesystem path from which the Session
bundle name will be generated. Must not be specified if the Session is
specified. If needed and left unspecified, will assume a default value.
files: (list of strings) An optional list of files that will be copied into the
Session bundle before starting the Session. Must not be specified if the
Session is specified and has already been started.
config: (SessionConfiguration) An optional configuration to use for starting
the Session. Must not be specified if the Session is specified and has already
been started (will be ignored).
If needed and left unspecified, will assume a default value.
session: (SharedSessionPtr) An optional SharedSessionPtr. Specifying this
argument overrides the other Session configuration options.
This Session must not have a network already loaded in the runtime engine
instance that it is managing.
- getLink(*args, **kwargs)
- getLink(self, index) -> SharedLinkPtr
SharedLinkPtr
Network::getLink(int index) const
- getLinkDestination(self, name)
- Deprecated in 1.5. Use getLink(i).getDestination() instead.
Behavior matches that of obsolete getLinkDestination(), and should not be used
except to maintain old code.
- getLinkNames(self)
- Deprecated in 1.5. Use getNumLinkPolicies() instead.
Behavior matches that of obsolete getLinkNames(), and should not be used
except to maintain old code.
- getLinkSource(self, name)
- Deprecated in 1.5. Use getLink(i).getSource() instead.
Behavior matches that of obsolete getLinkSource(), and should not be used
except to maintain old code.
- getNumLinkPolicies(*args, **kwargs)
- getNumLinkPolicies(self) -> size_t
size_t
Network::getNumLinkPolicies() const
- hasLink(self, name)
- Deprecated in 1.5. Use getNumLinkPolicies() instead.
Behavior matches that of obsolete hasLink(), and should not be used
except to maintain old code.
- link(self, source, destination, linkType='Link', atIndex=-1, **keywds)
- link(self, source, destination, linkType="Link", **keywds)
Adds a link policy to the network connecting the source and destination.
The link policy type determines the set of parameters necessary to fully
configure the link.
Returns the index of the link policy within the network, as link policies
are kept in the order they are added (unless specified otherwise).
Parameters:
-----------
source: (string)
The name of the link source element, which must be contained by this network.
destination: (string)
The name of the link destination element, which must be contained by this
network.
linkType: (string)
The link policy type name which is used to define the available parameters.
**keywds:
All remaining keyword arguments are treated as parameter name-value pairs,
and the parameters of the link policy are set from these values.
Current Link Policies
---------------------
Link
~~~~
Links two nodes to each other. It is the default link policy if you don't specify
a link type. It has the following additional parameters:
sourceOutputName: Default is ""
destinationInputName: Default is ""
inputOffset: offset from beginning of input. Default is 0.
outputOffset: offset from beginning of output. Default is 0.
elementCount: how many elements to link. Default is all elements.
FanIn
~~~~~
Links nodes or regions with multi-dimensional layout to each other.
Links the output to all the inputs receptive fields along each dimension.
sourceOutputName: Default is ""
destinationInputName: Default is ""
overlap: a list of integers representing overlap between adjacent
receptive fields per dimension. Default is 0 (no overlap)
SensorLink
~~~~~~~~~~
Links a node (typically a sensor) to a region and divides the node's output
between all region's nodes.
sourceOutputName: Default is ""
destinationInputName: Default is ""
overlap: a list of integers representing overlap between adjacent
receptive fields per dimension. Default is 0 (no overlap)
sourceDims: a list of integers representing the dimensions of the
output. Default is 1-D.
- removeElement(*args, **kwargs)
- removeElement(self, name, removeInvalidLinks)
void
Network::removeElement(const std::string &name, bool
removeInvalidLinks)
Dereference the named element of this Network.
Will throw a std::invalid_argument exception if no such named child
exists in the Network. Does not remove any link policies. Use
getInvalidLinkPolicies() to find links that have been invalidated by
the removal.
- removeLink(*args, **kwargs)
- removeLink(self, index)
void
Network::removeLink(int index)
Remove a stored LinkPolicy instance from this Network.
Deletes the LinkPolicy instance if its name matches, and removes that
name from the instance order list maintained internally. Throws an
exception if the named policy instance has not been stored. Does not
require revalidation of the remaining LinkPolicy instances, as
removing a LinkPolicy should never invalidate the Network (as opposed
to removing an element or resizing a Region, which may invalidate any
connected LinkPolicy instances).
Parameters:
-----------
name: (string) The name of a stored policy instance.
Data descriptors defined here:
- thisown
- The membership flag
Data and other attributes defined here:
- __swig_destroy__ = <built-in function delete_Network>
Methods inherited from NetworkElement:
- __eq__(*args, **kwargs)
- __eq__(self, other) -> bool
- __getitem__(self, name)
- __iter__(self)
- __ne__(*args, **kwargs)
- __ne__(self, other) -> bool
- __str__(*args, **kwargs)
- __str__(self) -> string
std::string
htmtools::NetworkElement::__str__() const
- addElementReference(*args, **kwargs)
- addElementReference(self, name, element, maxDeepCopyDepth)
void NetworkElement::addElementReference(const std::string &name,
const NetworkElement &element, int maxDeepCopyDepth)
Interface for adding child elements to the current NetworkElement.
Not supported by all derived types of NetworkElement.
- addXMLExtendedAttribute(*args, **kwargs)
- addXMLExtendedAttribute(self, key, value)
void
NetworkElement::addXMLExtendedAttribute(const std::string &key, const
std::string &value)
Adds an attribute to the element that will be written out when
writeXML() is called.
Only supported to top-level network objects at present.
- addXMLExtendedElement(*args, **kwargs)
- addXMLExtendedElement(self, element)
void NetworkElement::addXMLExtendedElement(const ExtendedElement
&element)
Adds a namespaced XML element will be written out when writeXML() is
called.
- allowVisit(*args)
- allowVisit(self, visitor)
allowVisit(self, path, visitor)
void
NetworkElement::allowVisit(const std::string &path,
NetworkElementVisitor &visitor) const
- attachSession(*args, **kwargs)
- attachSession(self, session, downloadToSession=True, preserveUpdateNotifier=True)
void
NetworkElement::attachSession(const nta::SharedSessionPtr &session,
bool preserveUpdateNotifier=true)
attachSession associates a Session object with the current
NetworkElement reference and all references to sub-elements contained
by this NetworkElement.
- beginXMLExtendedAttributes(*args, **kwargs)
- beginXMLExtendedAttributes(self) -> const_iterator
ExtendedAttributes::const_iterator
NetworkElement::beginXMLExtendedAttributes() const
- beginXMLExtendedElements(*args, **kwargs)
- beginXMLExtendedElements(self) -> htmtools::ExtendedElements::const_iterator
ExtendedElements::const_iterator
NetworkElement::beginXMLExtendedElements() const
- bindTo(*args, **kwargs)
- bindTo(self, h)
void
NetworkElement::bindTo(PyObject *h)
Internal call for creating a Python NetworkElement bindings from
inside C++ code.
- clearXMLExtendedAttributes(*args, **kwargs)
- clearXMLExtendedAttributes(self)
void
NetworkElement::clearXMLExtendedAttributes()
Removes all attributes attached to the XML description of the network
element.
- clearXMLExtendedElements(*args, **kwargs)
- clearXMLExtendedElements(self)
void
NetworkElement::clearXMLExtendedElements()
Removes all XML elements attached to the XML description of the
network element.
- deepCopy(*args)
- NetworkElement NetworkElement::deepCopy(int maxDepth=-1) const
Create a copy of this NetworkElement and some or all of the elements
it contains.
Recurses through contained elements and links making deep copies of
each until reaching the specified depth, after which all contained
elements are referenced rather than copied. The default maxDepth is -1,
which indicates that the recursion should proceed to the bottom of the
containment hierarchy, regardless of depth.
- detachSession(*args, **kwargs)
- detachSession(self, preserveUpdateNotifier=True, checkReferences=True)
void
NetworkElement::detachSession(bool preserveUpdateNotifier=true, bool
checkReferences=true)
Called to shut down the runtime engine, leaving all associated
RuntimeElements in an invalid state.
Typically only called from the last RuntimeElement destructor.
Also supports manual finalization of RuntimeElements from Java.
- downCast(self)
- Checks the 'true' type of a generic NetworkElement and downcasts to that type,
returning the result of the downcast. If the type is not recognized no
downcast takes place and the current instance is returned.
This functionality is only available in Python, and allows, for example,
use of Node-specific methods on returned NetworkElements that are
actually Nodes.
It is uncommon to need to call downCast() directly.
This method is called automatically from the Python bindings
for methods like:
NetworkElement::getElement(name)
NetworkElement::getContainer()
Region::getTemplateElement()
NetworkElementIterator::getCurrent()
Returns: (an instance of a subclass of NetworkElement)
- endXMLExtendedAttributes(*args, **kwargs)
- endXMLExtendedAttributes(self) -> const_iterator
ExtendedAttributes::const_iterator
NetworkElement::endXMLExtendedAttributes() const
- endXMLExtendedElements(*args, **kwargs)
- endXMLExtendedElements(self) -> htmtools::ExtendedElements::const_iterator
ExtendedElements::const_iterator
NetworkElement::endXMLExtendedElements() const
- evaluateLinks(*args)
- evaluateLinks(self, linkSet)
evaluateLinks(self) -> LinkSet
LinkSet htmtools::NetworkElement::evaluateLinks() const
Fill in a LinkSet from the stored LinkPolicies.
Most NetworkElements will not store any LinkPolicies ( Node and Region
do not store LinkPolicies). Networks do store LinkPolicies, and will
delegate this call to their LinkPolicyContainer. NetworkElements that
act as containers (such as Networks and Regions) also recurse on their
sub-elements calling evaluateLinks on each.
( LinkSet or void) If using the version that takes a LinkSet as an
argument, adds to the LinkSet and returns nothing. Otherwise, returns
a new LinkSet that contains only the links from the LinkPolicies
stored in this NetworkElement container.
Parameters:
-----------
linkSet: ( LinkSet) Optional output LinkSet to add the links to. If
unspecified, a new LinkSet will be returned. If specified, does not
clear existing links in the LinkSet.
- getContainer(self, up=1)
- NetworkElement NetworkElement::getContainer(size_t up=1) const
Gets the container NetworkElement from which this NetworkElement was
retrieved with a call to getElement() (or through use of a
NetworkElementIterator).
Will fail by throwing a std::runtime_error for NetworkElements that
were created in isolation (check hasContainer()).
Parameters
----------
up (size)
If 'up' is 1, gets the immediate parent.
If 'up' greater than 1, recurses up the tree until reaching the requested
container.
If 'up' is 0, gets the current element.
- getContainerAtDepth(self, depth)
- NetworkElement NetworkElement::getContainerAtDepth(size_t depth) const
Identical to: getContainer(getDepth() - depth)
Gets the container NetworkElement from which this NetworkElement was
retrieved with a call to getElement() (or through use of a
NetworkElementIterator).
Will fail by throwing a std::runtime_error for NetworkElements that
were created in isolation (check hasContainer()).
Parameters
----------
depth (size)
The depth, counting down from the root (which is at depth 0) at which
to select a container of the current element.
- getDefaultInput(*args, **kwargs)
- getDefaultInput(self) -> string
string NetworkElement::getDefaultInput() const
- getDefaultOutput(*args, **kwargs)
- getDefaultOutput(self) -> string
string NetworkElement::getDefaultO
| |