def testGetParametersCustomRegions(self):

        Network.cleanup()  # removes all previous registrations
        registerAllAdvancedRegions()
        json_list = Network.getRegistrations()
        #print(json_list)
        y = json.loads(json_list)
        self.assertTrue("py.ColumnPoolerRegion" in y)

        net = Network()
        #print(net.getSpecJSON("py.ColumnPoolerRegion"))
        cp = net.addRegion(
            "py.ColumnPoolerRegion", "py.ColumnPoolerRegion", """{ 
	"activationThresholdDistal": 20,
	"cellCount": 4096,
	"connectedPermanenceDistal": 0.5,
	"connectedPermanenceProximal": 0.5,
	"initialDistalPermanence": 0.51,
	"initialProximalPermanence": 0.6,
	"minThresholdProximal": 5,
	"sampleSizeDistal": 30,
	"sampleSizeProximal": 10,
	"sdrSize": 40,
	"synPermDistalDec": 0.001,
	"synPermDistalInc": 0.1,
	"synPermProximalDec": 0.001,
	"synPermProximalInc": 0.1
}""")

        # expected results from getParameters()  (in Spec order)
        expected = """{
  "learningMode": true,
  "onlineLearning": false,
  "cellCount": 4096,
  "inputWidth": 16384,
  "numOtherCorticalColumns": 0,
  "sdrSize": 40,
  "maxSdrSize": 0,
  "minSdrSize": 0,
  "synPermProximalInc": 0.100000,
  "synPermProximalDec": 0.001000,
  "initialProximalPermanence": 0.600000,
  "sampleSizeProximal": 10,
  "minThresholdProximal": 5,
  "connectedPermanenceProximal": 0.500000,
  "predictedInhibitionThreshold": 20.000000,
  "synPermDistalInc": 0.100000,
  "synPermDistalDec": 0.001000,
  "initialDistalPermanence": 0.510000,
  "sampleSizeDistal": 30,
  "activationThresholdDistal": 20,
  "connectedPermanenceDistal": 0.500000,
  "inertiaFactor": 1.000000,
  "seed": 42,
  "defaultOutputType": "active"
}"""

        json_list = cp.getParameters()
        #print(json_list)
        self.assertEqual(json_list, expected)
    def testGetParametersGridCell(self):
        # a test of arrays in parameters
        Network.cleanup()  # removes all previous registrations
        registerAllAdvancedRegions()
        json_list = Network.getRegistrations()
        #print(json_list)
        y = json.loads(json_list)
        self.assertTrue("py.GridCellLocationRegion" in y)

        # only provide one orentation to shorten the test.  Full test in location_region_test.py
        net = Network()
        #print(net.getSpecJSON("py.GridCellLocationRegion"))
        cp = net.addRegion(
            "grid", "py.GridCellLocationRegion", """{ 
  "moduleCount": 1,
  "cellsPerAxis": 10,
  "scale": [1],
  "orientation": [0.5],
  "anchorInputSize": 1,
  "activeFiringRate": 10 
}""")

        # expected results from getParameters()  (in Spec order)
        expected = """{
  "moduleCount": 1,
  "cellsPerAxis": 10,
  "scale": [1],
  "orientation": [0.5],
  "anchorInputSize": 1,
  "activeFiringRate": 10.000000,
  "bumpSigma": 0.181720,
  "activationThreshold": 10,
  "initialPermanence": 0.210000,
  "connectedPermanence": 0.500000,
  "learningThreshold": 10,
  "sampleSize": 20,
  "permanenceIncrement": 0.100000,
  "permanenceDecrement": 0.000000,
  "maxSynapsesPerSegment": -1,
  "bumpOverlapMethod": "probabilistic",
  "learningMode": false,
  "dualPhase": true,
  "dimensions": 2,
  "seed": 42
}"""

        json_list = cp.getParameters()
        #print(json_list)
        self.assertEqual(json_list, expected)
Exemple #3
0
    def setUp(self):
        registerAllAdvancedRegions()

        self._params = cortical_params
        
        L4Params = {param.split("_")[1]:value for param, value in self._params.items() if param.startswith("l4")}
        L6aParams = {param.split("_")[1]:value for param, value in self._params.items() if param.startswith("l6a")}
        # Configure L6a self._htm_parameters
        numModules = L6aParams["moduleCount"]
        L6aParams["scale"] = [L6aParams["scale"]] * numModules
        angle = L6aParams["orientation"] // numModules
        orientation = list(range(angle // 2, angle * numModules, angle))
        L6aParams["orientation"] = np.radians(orientation).tolist()
                
        self.network = self._create_network(L4Params, L6aParams)
 def setUpClass(cls):
     registerAllAdvancedRegions()
from htm.bindings.engine_internal import Network
from htm.advanced.support.register_regions import registerAllAdvancedRegions

registerAllAdvancedRegions()
""" Creating network instance. """
config = """
        {network: [
            {addRegion: {name: "encoder", type: "RDSEEncoderRegion", params: {size: 1000, sparsity: 0.2, radius: 0.03, seed: 2019, noise: 0.01}}},
            {addRegion: {name: "sp", type: "SPRegion", params: {columnCount: 2048, globalInhibition: true}}},
            {addRegion: {name: "tm", type: "TMRegion", params: {cellsPerColumn: 8, orColumnOutputs: true}}},
            {addRegion: {name: "apicalTM", type: "py.ApicalTMPairRegion", params: {columnCount : 2048, basalInputWidth : 10, cellsPerColumn: 8, implementation: ApicalTiebreak}}},
            {addLink:   {src: "encoder.encoded", dest: "sp.bottomUpIn"}},
            {addLink:   {src: "sp.bottomUpOut", dest: "tm.bottomUpIn"}},
            {addLink:   {src: "sp.bottomUpOut", dest: "apicalTM.activeColumns"}}
        ]}"""
net = Network()
net.configure(config)

#  feed data to RDSE encoder via its "sensedValue" parameter.
net.getRegion('encoder').setParameterReal64('sensedValue', 100)
net.run(10)  # Execute iteration of the Network object

print(net.getRegion('tm'))
print(net.getRegion('apicalTM'))

print(net.getRegion('tm').getConnections(
    ""))  # can be called because of this draft PR

print(
    net.getRegion('apicalTM').getConnections("")
)  # returns always None, it is region implemented in python, but it has not override getConnections