partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | save_vocab | Save the vocabulary to a file so the model can be reloaded.
Parameters
----------
count : a list of tuple and list
count[0] is a list : the number of rare words,
count[1:] are tuples : the number of occurrence of each word,
e.g. [['UNK', 418391], (b'the', 1061396), (b'of', 593677), ... | tensorlayer/nlp.py | def save_vocab(count=None, name='vocab.txt'):
"""Save the vocabulary to a file so the model can be reloaded.
Parameters
----------
count : a list of tuple and list
count[0] is a list : the number of rare words,
count[1:] are tuples : the number of occurrence of each word,
e.g. [... | def save_vocab(count=None, name='vocab.txt'):
"""Save the vocabulary to a file so the model can be reloaded.
Parameters
----------
count : a list of tuple and list
count[0] is a list : the number of rare words,
count[1:] are tuples : the number of occurrence of each word,
e.g. [... | [
"Save",
"the",
"vocabulary",
"to",
"a",
"file",
"so",
"the",
"model",
"can",
"be",
"reloaded",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/nlp.py#L795-L830 | [
"def",
"save_vocab",
"(",
"count",
"=",
"None",
",",
"name",
"=",
"'vocab.txt'",
")",
":",
"if",
"count",
"is",
"None",
":",
"count",
"=",
"[",
"]",
"pwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"vocabulary_size",
"=",
"len",
"(",
"count",
")",
"with"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | basic_tokenizer | Very basic tokenizer: split the sentence into a list of tokens.
Parameters
-----------
sentence : tensorflow.python.platform.gfile.GFile Object
_WORD_SPLIT : regular expression for word spliting.
Examples
--------
>>> see create_vocabulary
>>> from tensorflow.python.platform import gf... | tensorlayer/nlp.py | def basic_tokenizer(sentence, _WORD_SPLIT=re.compile(b"([.,!?\"':;)(])")):
"""Very basic tokenizer: split the sentence into a list of tokens.
Parameters
-----------
sentence : tensorflow.python.platform.gfile.GFile Object
_WORD_SPLIT : regular expression for word spliting.
Examples
------... | def basic_tokenizer(sentence, _WORD_SPLIT=re.compile(b"([.,!?\"':;)(])")):
"""Very basic tokenizer: split the sentence into a list of tokens.
Parameters
-----------
sentence : tensorflow.python.platform.gfile.GFile Object
_WORD_SPLIT : regular expression for word spliting.
Examples
------... | [
"Very",
"basic",
"tokenizer",
":",
"split",
"the",
"sentence",
"into",
"a",
"list",
"of",
"tokens",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/nlp.py#L836-L870 | [
"def",
"basic_tokenizer",
"(",
"sentence",
",",
"_WORD_SPLIT",
"=",
"re",
".",
"compile",
"(",
"b\"([.,!?\\\"':;)(])\"",
")",
")",
":",
"words",
"=",
"[",
"]",
"sentence",
"=",
"tf",
".",
"compat",
".",
"as_bytes",
"(",
"sentence",
")",
"for",
"space_separ... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | create_vocabulary | r"""Create vocabulary file (if it does not exist yet) from data file.
Data file is assumed to contain one sentence per line. Each sentence is
tokenized and digits are normalized (if normalize_digits is set).
Vocabulary contains the most-frequent tokens up to max_vocabulary_size.
We write it to vocabula... | tensorlayer/nlp.py | def create_vocabulary(
vocabulary_path, data_path, max_vocabulary_size, tokenizer=None, normalize_digits=True,
_DIGIT_RE=re.compile(br"\d"), _START_VOCAB=None
):
r"""Create vocabulary file (if it does not exist yet) from data file.
Data file is assumed to contain one sentence per line. Each sen... | def create_vocabulary(
vocabulary_path, data_path, max_vocabulary_size, tokenizer=None, normalize_digits=True,
_DIGIT_RE=re.compile(br"\d"), _START_VOCAB=None
):
r"""Create vocabulary file (if it does not exist yet) from data file.
Data file is assumed to contain one sentence per line. Each sen... | [
"r",
"Create",
"vocabulary",
"file",
"(",
"if",
"it",
"does",
"not",
"exist",
"yet",
")",
"from",
"data",
"file",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/nlp.py#L873-L932 | [
"def",
"create_vocabulary",
"(",
"vocabulary_path",
",",
"data_path",
",",
"max_vocabulary_size",
",",
"tokenizer",
"=",
"None",
",",
"normalize_digits",
"=",
"True",
",",
"_DIGIT_RE",
"=",
"re",
".",
"compile",
"(",
"br\"\\d\"",
")",
",",
"_START_VOCAB",
"=",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | initialize_vocabulary | Initialize vocabulary from file, return the `word_to_id` (dictionary)
and `id_to_word` (list).
We assume the vocabulary is stored one-item-per-line, so a file will result in a vocabulary {"dog": 0, "cat": 1}, and this function will also return the reversed-vocabulary ["dog", "cat"].
Parameters
-------... | tensorlayer/nlp.py | def initialize_vocabulary(vocabulary_path):
"""Initialize vocabulary from file, return the `word_to_id` (dictionary)
and `id_to_word` (list).
We assume the vocabulary is stored one-item-per-line, so a file will result in a vocabulary {"dog": 0, "cat": 1}, and this function will also return the reversed-voc... | def initialize_vocabulary(vocabulary_path):
"""Initialize vocabulary from file, return the `word_to_id` (dictionary)
and `id_to_word` (list).
We assume the vocabulary is stored one-item-per-line, so a file will result in a vocabulary {"dog": 0, "cat": 1}, and this function will also return the reversed-voc... | [
"Initialize",
"vocabulary",
"from",
"file",
"return",
"the",
"word_to_id",
"(",
"dictionary",
")",
"and",
"id_to_word",
"(",
"list",
")",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/nlp.py#L935-L978 | [
"def",
"initialize_vocabulary",
"(",
"vocabulary_path",
")",
":",
"if",
"gfile",
".",
"Exists",
"(",
"vocabulary_path",
")",
":",
"rev_vocab",
"=",
"[",
"]",
"with",
"gfile",
".",
"GFile",
"(",
"vocabulary_path",
",",
"mode",
"=",
"\"rb\"",
")",
"as",
"f",... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | sentence_to_token_ids | Convert a string to list of integers representing token-ids.
For example, a sentence "I have a dog" may become tokenized into
["I", "have", "a", "dog"] and with vocabulary {"I": 1, "have": 2,
"a": 4, "dog": 7"} this function will return [1, 2, 4, 7].
Parameters
-----------
sentence : tensorflo... | tensorlayer/nlp.py | def sentence_to_token_ids(
sentence, vocabulary, tokenizer=None, normalize_digits=True, UNK_ID=3, _DIGIT_RE=re.compile(br"\d")
):
"""Convert a string to list of integers representing token-ids.
For example, a sentence "I have a dog" may become tokenized into
["I", "have", "a", "dog"] and with vocab... | def sentence_to_token_ids(
sentence, vocabulary, tokenizer=None, normalize_digits=True, UNK_ID=3, _DIGIT_RE=re.compile(br"\d")
):
"""Convert a string to list of integers representing token-ids.
For example, a sentence "I have a dog" may become tokenized into
["I", "have", "a", "dog"] and with vocab... | [
"Convert",
"a",
"string",
"to",
"list",
"of",
"integers",
"representing",
"token",
"-",
"ids",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/nlp.py#L981-L1014 | [
"def",
"sentence_to_token_ids",
"(",
"sentence",
",",
"vocabulary",
",",
"tokenizer",
"=",
"None",
",",
"normalize_digits",
"=",
"True",
",",
"UNK_ID",
"=",
"3",
",",
"_DIGIT_RE",
"=",
"re",
".",
"compile",
"(",
"br\"\\d\"",
")",
")",
":",
"if",
"tokenizer... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | data_to_token_ids | Tokenize data file and turn into token-ids using given vocabulary file.
This function loads data line-by-line from data_path, calls the above
sentence_to_token_ids, and saves the result to target_path. See comment
for sentence_to_token_ids on the details of token-ids format.
Parameters
-----------... | tensorlayer/nlp.py | def data_to_token_ids(
data_path, target_path, vocabulary_path, tokenizer=None, normalize_digits=True, UNK_ID=3,
_DIGIT_RE=re.compile(br"\d")
):
"""Tokenize data file and turn into token-ids using given vocabulary file.
This function loads data line-by-line from data_path, calls the above
s... | def data_to_token_ids(
data_path, target_path, vocabulary_path, tokenizer=None, normalize_digits=True, UNK_ID=3,
_DIGIT_RE=re.compile(br"\d")
):
"""Tokenize data file and turn into token-ids using given vocabulary file.
This function loads data line-by-line from data_path, calls the above
s... | [
"Tokenize",
"data",
"file",
"and",
"turn",
"into",
"token",
"-",
"ids",
"using",
"given",
"vocabulary",
"file",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/nlp.py#L1017-L1060 | [
"def",
"data_to_token_ids",
"(",
"data_path",
",",
"target_path",
",",
"vocabulary_path",
",",
"tokenizer",
"=",
"None",
",",
"normalize_digits",
"=",
"True",
",",
"UNK_ID",
"=",
"3",
",",
"_DIGIT_RE",
"=",
"re",
".",
"compile",
"(",
"br\"\\d\"",
")",
")",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | moses_multi_bleu | Calculate the bleu score for hypotheses and references
using the MOSES ulti-bleu.perl script.
Parameters
------------
hypotheses : numpy.array.string
A numpy array of strings where each string is a single example.
references : numpy.array.string
A numpy array of strings where each s... | tensorlayer/nlp.py | def moses_multi_bleu(hypotheses, references, lowercase=False):
"""Calculate the bleu score for hypotheses and references
using the MOSES ulti-bleu.perl script.
Parameters
------------
hypotheses : numpy.array.string
A numpy array of strings where each string is a single example.
referen... | def moses_multi_bleu(hypotheses, references, lowercase=False):
"""Calculate the bleu score for hypotheses and references
using the MOSES ulti-bleu.perl script.
Parameters
------------
hypotheses : numpy.array.string
A numpy array of strings where each string is a single example.
referen... | [
"Calculate",
"the",
"bleu",
"score",
"for",
"hypotheses",
"and",
"references",
"using",
"the",
"MOSES",
"ulti",
"-",
"bleu",
".",
"perl",
"script",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/nlp.py#L1063-L1139 | [
"def",
"moses_multi_bleu",
"(",
"hypotheses",
",",
"references",
",",
"lowercase",
"=",
"False",
")",
":",
"if",
"np",
".",
"size",
"(",
"hypotheses",
")",
"==",
"0",
":",
"return",
"np",
".",
"float32",
"(",
"0.0",
")",
"# Get MOSES multi-bleu script",
"t... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | SimpleVocabulary.word_to_id | Returns the integer id of a word string. | tensorlayer/nlp.py | def word_to_id(self, word):
"""Returns the integer id of a word string."""
if word in self._vocab:
return self._vocab[word]
else:
return self._unk_id | def word_to_id(self, word):
"""Returns the integer id of a word string."""
if word in self._vocab:
return self._vocab[word]
else:
return self._unk_id | [
"Returns",
"the",
"integer",
"id",
"of",
"a",
"word",
"string",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/nlp.py#L226-L231 | [
"def",
"word_to_id",
"(",
"self",
",",
"word",
")",
":",
"if",
"word",
"in",
"self",
".",
"_vocab",
":",
"return",
"self",
".",
"_vocab",
"[",
"word",
"]",
"else",
":",
"return",
"self",
".",
"_unk_id"
] | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | Vocabulary.word_to_id | Returns the integer word id of a word string. | tensorlayer/nlp.py | def word_to_id(self, word):
"""Returns the integer word id of a word string."""
if word in self.vocab:
return self.vocab[word]
else:
return self.unk_id | def word_to_id(self, word):
"""Returns the integer word id of a word string."""
if word in self.vocab:
return self.vocab[word]
else:
return self.unk_id | [
"Returns",
"the",
"integer",
"word",
"id",
"of",
"a",
"word",
"string",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/nlp.py#L320-L325 | [
"def",
"word_to_id",
"(",
"self",
",",
"word",
")",
":",
"if",
"word",
"in",
"self",
".",
"vocab",
":",
"return",
"self",
".",
"vocab",
"[",
"word",
"]",
"else",
":",
"return",
"self",
".",
"unk_id"
] | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | Vocabulary.id_to_word | Returns the word string of an integer word id. | tensorlayer/nlp.py | def id_to_word(self, word_id):
"""Returns the word string of an integer word id."""
if word_id >= len(self.reverse_vocab):
return self.reverse_vocab[self.unk_id]
else:
return self.reverse_vocab[word_id] | def id_to_word(self, word_id):
"""Returns the word string of an integer word id."""
if word_id >= len(self.reverse_vocab):
return self.reverse_vocab[self.unk_id]
else:
return self.reverse_vocab[word_id] | [
"Returns",
"the",
"word",
"string",
"of",
"an",
"integer",
"word",
"id",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/nlp.py#L327-L332 | [
"def",
"id_to_word",
"(",
"self",
",",
"word_id",
")",
":",
"if",
"word_id",
">=",
"len",
"(",
"self",
".",
"reverse_vocab",
")",
":",
"return",
"self",
".",
"reverse_vocab",
"[",
"self",
".",
"unk_id",
"]",
"else",
":",
"return",
"self",
".",
"reverse... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | basic_clean_str | Tokenization/string cleaning for a datasets. | examples/text_generation/tutorial_generate_text.py | def basic_clean_str(string):
"""Tokenization/string cleaning for a datasets."""
string = re.sub(r"\n", " ", string) # '\n' --> ' '
string = re.sub(r"\'s", " \'s", string) # it's --> it 's
string = re.sub(r"\’s", " \'s", string)
string = re.sub(r"\'ve", " have", string) # they've --> t... | def basic_clean_str(string):
"""Tokenization/string cleaning for a datasets."""
string = re.sub(r"\n", " ", string) # '\n' --> ' '
string = re.sub(r"\'s", " \'s", string) # it's --> it 's
string = re.sub(r"\’s", " \'s", string)
string = re.sub(r"\'ve", " have", string) # they've --> t... | [
"Tokenization",
"/",
"string",
"cleaning",
"for",
"a",
"datasets",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/examples/text_generation/tutorial_generate_text.py#L39-L78 | [
"def",
"basic_clean_str",
"(",
"string",
")",
":",
"string",
"=",
"re",
".",
"sub",
"(",
"r\"\\n\"",
",",
"\" \"",
",",
"string",
")",
"# '\\n' --> ' '",
"string",
"=",
"re",
".",
"sub",
"(",
"r\"\\'s\"",
",",
"\" \\'s\"",
",",
"string",
")",
"# it'... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | main_restore_embedding_layer | How to use Embedding layer, and how to convert IDs to vector,
IDs to words, etc. | examples/text_generation/tutorial_generate_text.py | def main_restore_embedding_layer():
"""How to use Embedding layer, and how to convert IDs to vector,
IDs to words, etc.
"""
# Step 1: Build the embedding matrix and load the existing embedding matrix.
vocabulary_size = 50000
embedding_size = 128
model_file_name = "model_word2vec_50k_128"
... | def main_restore_embedding_layer():
"""How to use Embedding layer, and how to convert IDs to vector,
IDs to words, etc.
"""
# Step 1: Build the embedding matrix and load the existing embedding matrix.
vocabulary_size = 50000
embedding_size = 128
model_file_name = "model_word2vec_50k_128"
... | [
"How",
"to",
"use",
"Embedding",
"layer",
"and",
"how",
"to",
"convert",
"IDs",
"to",
"vector",
"IDs",
"to",
"words",
"etc",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/examples/text_generation/tutorial_generate_text.py#L132-L182 | [
"def",
"main_restore_embedding_layer",
"(",
")",
":",
"# Step 1: Build the embedding matrix and load the existing embedding matrix.",
"vocabulary_size",
"=",
"50000",
"embedding_size",
"=",
"128",
"model_file_name",
"=",
"\"model_word2vec_50k_128\"",
"batch_size",
"=",
"None",
"p... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | main_lstm_generate_text | Generate text by Synced sequence input and output. | examples/text_generation/tutorial_generate_text.py | def main_lstm_generate_text():
"""Generate text by Synced sequence input and output."""
# rnn model and update (describtion: see tutorial_ptb_lstm.py)
init_scale = 0.1
learning_rate = 1.0
max_grad_norm = 5
sequence_length = 20
hidden_size = 200
max_epoch = 4
max_max_epoch = 100
... | def main_lstm_generate_text():
"""Generate text by Synced sequence input and output."""
# rnn model and update (describtion: see tutorial_ptb_lstm.py)
init_scale = 0.1
learning_rate = 1.0
max_grad_norm = 5
sequence_length = 20
hidden_size = 200
max_epoch = 4
max_max_epoch = 100
... | [
"Generate",
"text",
"by",
"Synced",
"sequence",
"input",
"and",
"output",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/examples/text_generation/tutorial_generate_text.py#L185-L362 | [
"def",
"main_lstm_generate_text",
"(",
")",
":",
"# rnn model and update (describtion: see tutorial_ptb_lstm.py)",
"init_scale",
"=",
"0.1",
"learning_rate",
"=",
"1.0",
"max_grad_norm",
"=",
"5",
"sequence_length",
"=",
"20",
"hidden_size",
"=",
"200",
"max_epoch",
"=",... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | createAndStartSwarm | Create and start a swarm job.
Args:
client - A string identifying the calling client. There is a small limit
for the length of the value. See ClientJobsDAO.CLIENT_MAX_LEN.
clientInfo - JSON encoded dict of client specific information.
clientKey - Foreign key. Limited in length, see ClientJobsDAO.... | src/nupic/swarming/api.py | def createAndStartSwarm(client, clientInfo="", clientKey="", params="",
minimumWorkers=None, maximumWorkers=None,
alreadyRunning=False):
"""Create and start a swarm job.
Args:
client - A string identifying the calling client. There is a small limit
for th... | def createAndStartSwarm(client, clientInfo="", clientKey="", params="",
minimumWorkers=None, maximumWorkers=None,
alreadyRunning=False):
"""Create and start a swarm job.
Args:
client - A string identifying the calling client. There is a small limit
for th... | [
"Create",
"and",
"start",
"a",
"swarm",
"job",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/api.py#L34-L69 | [
"def",
"createAndStartSwarm",
"(",
"client",
",",
"clientInfo",
"=",
"\"\"",
",",
"clientKey",
"=",
"\"\"",
",",
"params",
"=",
"\"\"",
",",
"minimumWorkers",
"=",
"None",
",",
"maximumWorkers",
"=",
"None",
",",
"alreadyRunning",
"=",
"False",
")",
":",
"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | getSwarmModelParams | Retrieve the Engine-level model params from a Swarm model
Args:
modelID - Engine-level model ID of the Swarm model
Returns:
JSON-encoded string containing Model Params | src/nupic/swarming/api.py | def getSwarmModelParams(modelID):
"""Retrieve the Engine-level model params from a Swarm model
Args:
modelID - Engine-level model ID of the Swarm model
Returns:
JSON-encoded string containing Model Params
"""
# TODO: the use of nupic.frameworks.opf.helpers.loadExperimentDescriptionScriptFromDir whe... | def getSwarmModelParams(modelID):
"""Retrieve the Engine-level model params from a Swarm model
Args:
modelID - Engine-level model ID of the Swarm model
Returns:
JSON-encoded string containing Model Params
"""
# TODO: the use of nupic.frameworks.opf.helpers.loadExperimentDescriptionScriptFromDir whe... | [
"Retrieve",
"the",
"Engine",
"-",
"level",
"model",
"params",
"from",
"a",
"Swarm",
"model"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/api.py#L73-L119 | [
"def",
"getSwarmModelParams",
"(",
"modelID",
")",
":",
"# TODO: the use of nupic.frameworks.opf.helpers.loadExperimentDescriptionScriptFromDir when",
"# retrieving module params results in a leakage of pf_base_descriptionNN and",
"# pf_descriptionNN module imports for every call to getSwarmModelP... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | enableConcurrencyChecks | Enable the diagnostic feature for debugging unexpected concurrency in
acquiring ConnectionWrapper instances.
NOTE: This MUST be done early in your application's execution, BEFORE any
accesses to ConnectionFactory or connection policies from your application
(including imports and sub-imports of your app).
P... | src/nupic/database/connection.py | def enableConcurrencyChecks(maxConcurrency, raiseException=True):
""" Enable the diagnostic feature for debugging unexpected concurrency in
acquiring ConnectionWrapper instances.
NOTE: This MUST be done early in your application's execution, BEFORE any
accesses to ConnectionFactory or connection policies from ... | def enableConcurrencyChecks(maxConcurrency, raiseException=True):
""" Enable the diagnostic feature for debugging unexpected concurrency in
acquiring ConnectionWrapper instances.
NOTE: This MUST be done early in your application's execution, BEFORE any
accesses to ConnectionFactory or connection policies from ... | [
"Enable",
"the",
"diagnostic",
"feature",
"for",
"debugging",
"unexpected",
"concurrency",
"in",
"acquiring",
"ConnectionWrapper",
"instances",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L59-L83 | [
"def",
"enableConcurrencyChecks",
"(",
"maxConcurrency",
",",
"raiseException",
"=",
"True",
")",
":",
"global",
"g_max_concurrency",
",",
"g_max_concurrency_raise_exception",
"assert",
"maxConcurrency",
">=",
"0",
"g_max_concurrency",
"=",
"maxConcurrency",
"g_max_concurre... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _getCommonSteadyDBArgsDict | Returns a dictionary of arguments for DBUtils.SteadyDB.SteadyDBConnection
constructor. | src/nupic/database/connection.py | def _getCommonSteadyDBArgsDict():
""" Returns a dictionary of arguments for DBUtils.SteadyDB.SteadyDBConnection
constructor.
"""
return dict(
creator = pymysql,
host = Configuration.get('nupic.cluster.database.host'),
port = int(Configuration.get('nupic.cluster.database.port')),
user = ... | def _getCommonSteadyDBArgsDict():
""" Returns a dictionary of arguments for DBUtils.SteadyDB.SteadyDBConnection
constructor.
"""
return dict(
creator = pymysql,
host = Configuration.get('nupic.cluster.database.host'),
port = int(Configuration.get('nupic.cluster.database.port')),
user = ... | [
"Returns",
"a",
"dictionary",
"of",
"arguments",
"for",
"DBUtils",
".",
"SteadyDB",
".",
"SteadyDBConnection",
"constructor",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L643-L656 | [
"def",
"_getCommonSteadyDBArgsDict",
"(",
")",
":",
"return",
"dict",
"(",
"creator",
"=",
"pymysql",
",",
"host",
"=",
"Configuration",
".",
"get",
"(",
"'nupic.cluster.database.host'",
")",
",",
"port",
"=",
"int",
"(",
"Configuration",
".",
"get",
"(",
"'... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _getLogger | Gets a logger for the given class in this module | src/nupic/database/connection.py | def _getLogger(cls, logLevel=None):
""" Gets a logger for the given class in this module
"""
logger = logging.getLogger(
".".join(['com.numenta', _MODULE_NAME, cls.__name__]))
if logLevel is not None:
logger.setLevel(logLevel)
return logger | def _getLogger(cls, logLevel=None):
""" Gets a logger for the given class in this module
"""
logger = logging.getLogger(
".".join(['com.numenta', _MODULE_NAME, cls.__name__]))
if logLevel is not None:
logger.setLevel(logLevel)
return logger | [
"Gets",
"a",
"logger",
"for",
"the",
"given",
"class",
"in",
"this",
"module"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L660-L669 | [
"def",
"_getLogger",
"(",
"cls",
",",
"logLevel",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"\".\"",
".",
"join",
"(",
"[",
"'com.numenta'",
",",
"_MODULE_NAME",
",",
"cls",
".",
"__name__",
"]",
")",
")",
"if",
"logLevel"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | ConnectionFactory.get | Acquire a ConnectionWrapper instance that represents a connection
to the SQL server per nupic.cluster.database.* configuration settings.
NOTE: caller is responsible for calling the ConnectionWrapper instance's
release() method after using the connection in order to release resources.
Better yet, use th... | src/nupic/database/connection.py | def get(cls):
""" Acquire a ConnectionWrapper instance that represents a connection
to the SQL server per nupic.cluster.database.* configuration settings.
NOTE: caller is responsible for calling the ConnectionWrapper instance's
release() method after using the connection in order to release resources.
... | def get(cls):
""" Acquire a ConnectionWrapper instance that represents a connection
to the SQL server per nupic.cluster.database.* configuration settings.
NOTE: caller is responsible for calling the ConnectionWrapper instance's
release() method after using the connection in order to release resources.
... | [
"Acquire",
"a",
"ConnectionWrapper",
"instance",
"that",
"represents",
"a",
"connection",
"to",
"the",
"SQL",
"server",
"per",
"nupic",
".",
"cluster",
".",
"database",
".",
"*",
"configuration",
"settings",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L130-L167 | [
"def",
"get",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"_connectionPolicy",
"is",
"None",
":",
"logger",
"=",
"_getLogger",
"(",
"cls",
")",
"logger",
".",
"info",
"(",
"\"Creating db connection policy via provider %r\"",
",",
"cls",
".",
"_connectionPolicyInstan... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | ConnectionFactory._createDefaultPolicy | [private] Create the default database connection policy instance
Parameters:
----------------------------------------------------------------
retval: The default database connection policy instance | src/nupic/database/connection.py | def _createDefaultPolicy(cls):
""" [private] Create the default database connection policy instance
Parameters:
----------------------------------------------------------------
retval: The default database connection policy instance
"""
logger = _getLogger(cls)
logger.debug(
... | def _createDefaultPolicy(cls):
""" [private] Create the default database connection policy instance
Parameters:
----------------------------------------------------------------
retval: The default database connection policy instance
"""
logger = _getLogger(cls)
logger.debug(
... | [
"[",
"private",
"]",
"Create",
"the",
"default",
"database",
"connection",
"policy",
"instance"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L212-L235 | [
"def",
"_createDefaultPolicy",
"(",
"cls",
")",
":",
"logger",
"=",
"_getLogger",
"(",
"cls",
")",
"logger",
".",
"debug",
"(",
"\"Creating database connection policy: platform=%r; pymysql.VERSION=%r\"",
",",
"platform",
".",
"system",
"(",
")",
",",
"pymysql",
".",... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | ConnectionWrapper.release | Release the database connection and cursor
The receiver of the Connection instance MUST call this method in order
to reclaim resources | src/nupic/database/connection.py | def release(self):
""" Release the database connection and cursor
The receiver of the Connection instance MUST call this method in order
to reclaim resources
"""
self._logger.debug("Releasing: %r", self)
# Discard self from set of outstanding instances
if self._addedToInstanceSet:
t... | def release(self):
""" Release the database connection and cursor
The receiver of the Connection instance MUST call this method in order
to reclaim resources
"""
self._logger.debug("Releasing: %r", self)
# Discard self from set of outstanding instances
if self._addedToInstanceSet:
t... | [
"Release",
"the",
"database",
"connection",
"and",
"cursor"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L340-L370 | [
"def",
"release",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Releasing: %r\"",
",",
"self",
")",
"# Discard self from set of outstanding instances",
"if",
"self",
".",
"_addedToInstanceSet",
":",
"try",
":",
"self",
".",
"_clsOutstandingI... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | ConnectionWrapper._trackInstanceAndCheckForConcurrencyViolation | Check for concurrency violation and add self to
_clsOutstandingInstances.
ASSUMPTION: Called from constructor BEFORE _clsNumOutstanding is
incremented | src/nupic/database/connection.py | def _trackInstanceAndCheckForConcurrencyViolation(self):
""" Check for concurrency violation and add self to
_clsOutstandingInstances.
ASSUMPTION: Called from constructor BEFORE _clsNumOutstanding is
incremented
"""
global g_max_concurrency, g_max_concurrency_raise_exception
assert g_max_c... | def _trackInstanceAndCheckForConcurrencyViolation(self):
""" Check for concurrency violation and add self to
_clsOutstandingInstances.
ASSUMPTION: Called from constructor BEFORE _clsNumOutstanding is
incremented
"""
global g_max_concurrency, g_max_concurrency_raise_exception
assert g_max_c... | [
"Check",
"for",
"concurrency",
"violation",
"and",
"add",
"self",
"to",
"_clsOutstandingInstances",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L373-L409 | [
"def",
"_trackInstanceAndCheckForConcurrencyViolation",
"(",
"self",
")",
":",
"global",
"g_max_concurrency",
",",
"g_max_concurrency_raise_exception",
"assert",
"g_max_concurrency",
"is",
"not",
"None",
"assert",
"self",
"not",
"in",
"self",
".",
"_clsOutstandingInstances"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SingleSharedConnectionPolicy.close | Close the policy instance and its shared database connection. | src/nupic/database/connection.py | def close(self):
""" Close the policy instance and its shared database connection. """
self._logger.info("Closing")
if self._conn is not None:
self._conn.close()
self._conn = None
else:
self._logger.warning(
"close() called, but connection policy was alredy closed")
return | def close(self):
""" Close the policy instance and its shared database connection. """
self._logger.info("Closing")
if self._conn is not None:
self._conn.close()
self._conn = None
else:
self._logger.warning(
"close() called, but connection policy was alredy closed")
return | [
"Close",
"the",
"policy",
"instance",
"and",
"its",
"shared",
"database",
"connection",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L458-L467 | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Closing\"",
")",
"if",
"self",
".",
"_conn",
"is",
"not",
"None",
":",
"self",
".",
"_conn",
".",
"close",
"(",
")",
"self",
".",
"_conn",
"=",
"None",
"else",
":... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SingleSharedConnectionPolicy.acquireConnection | Get a Connection instance.
Parameters:
----------------------------------------------------------------
retval: A ConnectionWrapper instance. NOTE: Caller
is responsible for calling the ConnectionWrapper
instance's release() method or use it in a context manag... | src/nupic/database/connection.py | def acquireConnection(self):
""" Get a Connection instance.
Parameters:
----------------------------------------------------------------
retval: A ConnectionWrapper instance. NOTE: Caller
is responsible for calling the ConnectionWrapper
instance's release(... | def acquireConnection(self):
""" Get a Connection instance.
Parameters:
----------------------------------------------------------------
retval: A ConnectionWrapper instance. NOTE: Caller
is responsible for calling the ConnectionWrapper
instance's release(... | [
"Get",
"a",
"Connection",
"instance",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L470-L489 | [
"def",
"acquireConnection",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Acquiring connection\"",
")",
"# Check connection and attempt to re-establish it if it died (this is",
"# what PooledDB does)",
"self",
".",
"_conn",
".",
"_ping_check",
"(",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PooledConnectionPolicy.close | Close the policy instance and its database connection pool. | src/nupic/database/connection.py | def close(self):
""" Close the policy instance and its database connection pool. """
self._logger.info("Closing")
if self._pool is not None:
self._pool.close()
self._pool = None
else:
self._logger.warning(
"close() called, but connection policy was alredy closed")
return | def close(self):
""" Close the policy instance and its database connection pool. """
self._logger.info("Closing")
if self._pool is not None:
self._pool.close()
self._pool = None
else:
self._logger.warning(
"close() called, but connection policy was alredy closed")
return | [
"Close",
"the",
"policy",
"instance",
"and",
"its",
"database",
"connection",
"pool",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L528-L538 | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Closing\"",
")",
"if",
"self",
".",
"_pool",
"is",
"not",
"None",
":",
"self",
".",
"_pool",
".",
"close",
"(",
")",
"self",
".",
"_pool",
"=",
"None",
"else",
":... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PooledConnectionPolicy.acquireConnection | Get a connection from the pool.
Parameters:
----------------------------------------------------------------
retval: A ConnectionWrapper instance. NOTE: Caller
is responsible for calling the ConnectionWrapper
instance's release() method or use it in a context ... | src/nupic/database/connection.py | def acquireConnection(self):
""" Get a connection from the pool.
Parameters:
----------------------------------------------------------------
retval: A ConnectionWrapper instance. NOTE: Caller
is responsible for calling the ConnectionWrapper
instance's rel... | def acquireConnection(self):
""" Get a connection from the pool.
Parameters:
----------------------------------------------------------------
retval: A ConnectionWrapper instance. NOTE: Caller
is responsible for calling the ConnectionWrapper
instance's rel... | [
"Get",
"a",
"connection",
"from",
"the",
"pool",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L541-L558 | [
"def",
"acquireConnection",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Acquiring connection\"",
")",
"dbConn",
"=",
"self",
".",
"_pool",
".",
"connection",
"(",
"shareable",
"=",
"False",
")",
"connWrap",
"=",
"ConnectionWrapper",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PerTransactionConnectionPolicy.close | Close the policy instance. | src/nupic/database/connection.py | def close(self):
""" Close the policy instance. """
self._logger.info("Closing")
if self._opened:
self._opened = False
else:
self._logger.warning(
"close() called, but connection policy was alredy closed")
return | def close(self):
""" Close the policy instance. """
self._logger.info("Closing")
if self._opened:
self._opened = False
else:
self._logger.warning(
"close() called, but connection policy was alredy closed")
return | [
"Close",
"the",
"policy",
"instance",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L595-L605 | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Closing\"",
")",
"if",
"self",
".",
"_opened",
":",
"self",
".",
"_opened",
"=",
"False",
"else",
":",
"self",
".",
"_logger",
".",
"warning",
"(",
"\"close() called, b... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PerTransactionConnectionPolicy.acquireConnection | Create a Connection instance.
Parameters:
----------------------------------------------------------------
retval: A ConnectionWrapper instance. NOTE: Caller
is responsible for calling the ConnectionWrapper
instance's release() method or use it in a context ma... | src/nupic/database/connection.py | def acquireConnection(self):
""" Create a Connection instance.
Parameters:
----------------------------------------------------------------
retval: A ConnectionWrapper instance. NOTE: Caller
is responsible for calling the ConnectionWrapper
instance's relea... | def acquireConnection(self):
""" Create a Connection instance.
Parameters:
----------------------------------------------------------------
retval: A ConnectionWrapper instance. NOTE: Caller
is responsible for calling the ConnectionWrapper
instance's relea... | [
"Create",
"a",
"Connection",
"instance",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L608-L625 | [
"def",
"acquireConnection",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Acquiring connection\"",
")",
"dbConn",
"=",
"SteadyDB",
".",
"connect",
"(",
"*",
"*",
"_getCommonSteadyDBArgsDict",
"(",
")",
")",
"connWrap",
"=",
"ConnectionWr... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PerTransactionConnectionPolicy._releaseConnection | Release database connection and cursor; passed as a callback to
ConnectionWrapper | src/nupic/database/connection.py | def _releaseConnection(self, dbConn, cursor):
""" Release database connection and cursor; passed as a callback to
ConnectionWrapper
"""
self._logger.debug("Releasing connection")
# Close the cursor
cursor.close()
# ... then close the database connection
dbConn.close()
return | def _releaseConnection(self, dbConn, cursor):
""" Release database connection and cursor; passed as a callback to
ConnectionWrapper
"""
self._logger.debug("Releasing connection")
# Close the cursor
cursor.close()
# ... then close the database connection
dbConn.close()
return | [
"Release",
"database",
"connection",
"and",
"cursor",
";",
"passed",
"as",
"a",
"callback",
"to",
"ConnectionWrapper"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/connection.py#L628-L639 | [
"def",
"_releaseConnection",
"(",
"self",
",",
"dbConn",
",",
"cursor",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Releasing connection\"",
")",
"# Close the cursor",
"cursor",
".",
"close",
"(",
")",
"# ... then close the database connection",
"dbConn"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion.getSpec | Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getSpec`. | src/nupic/regions/knn_anomaly_classifier_region.py | def getSpec(cls):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getSpec`.
"""
ns = dict(
description=KNNAnomalyClassifierRegion.__doc__,
singleNodeOnly=True,
inputs=dict(
spBottomUpOut=dict(
description="""The output signal generated from the... | def getSpec(cls):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getSpec`.
"""
ns = dict(
description=KNNAnomalyClassifierRegion.__doc__,
singleNodeOnly=True,
inputs=dict(
spBottomUpOut=dict(
description="""The output signal generated from the... | [
"Overrides",
":",
"meth",
":",
"nupic",
".",
"bindings",
".",
"regions",
".",
"PyRegion",
".",
"PyRegion",
".",
"getSpec",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L79-L213 | [
"def",
"getSpec",
"(",
"cls",
")",
":",
"ns",
"=",
"dict",
"(",
"description",
"=",
"KNNAnomalyClassifierRegion",
".",
"__doc__",
",",
"singleNodeOnly",
"=",
"True",
",",
"inputs",
"=",
"dict",
"(",
"spBottomUpOut",
"=",
"dict",
"(",
"description",
"=",
"\... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion.getParameter | Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getParameter`. | src/nupic/regions/knn_anomaly_classifier_region.py | def getParameter(self, name, index=-1):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getParameter`.
"""
if name == "trainRecords":
return self.trainRecords
elif name == "anomalyThreshold":
return self.anomalyThreshold
elif name == "activeColumnCount":
return se... | def getParameter(self, name, index=-1):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getParameter`.
"""
if name == "trainRecords":
return self.trainRecords
elif name == "anomalyThreshold":
return self.anomalyThreshold
elif name == "activeColumnCount":
return se... | [
"Overrides",
":",
"meth",
":",
"nupic",
".",
"bindings",
".",
"regions",
".",
"PyRegion",
".",
"PyRegion",
".",
"getParameter",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L260-L275 | [
"def",
"getParameter",
"(",
"self",
",",
"name",
",",
"index",
"=",
"-",
"1",
")",
":",
"if",
"name",
"==",
"\"trainRecords\"",
":",
"return",
"self",
".",
"trainRecords",
"elif",
"name",
"==",
"\"anomalyThreshold\"",
":",
"return",
"self",
".",
"anomalyTh... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion.setParameter | Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.setParameter`. | src/nupic/regions/knn_anomaly_classifier_region.py | def setParameter(self, name, index, value):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.setParameter`.
"""
if name == "trainRecords":
# Ensure that the trainRecords can only be set to minimum of the ROWID in
# the saved states
if not (isinstance(value, float) or isins... | def setParameter(self, name, index, value):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.setParameter`.
"""
if name == "trainRecords":
# Ensure that the trainRecords can only be set to minimum of the ROWID in
# the saved states
if not (isinstance(value, float) or isins... | [
"Overrides",
":",
"meth",
":",
"nupic",
".",
"bindings",
".",
"regions",
".",
"PyRegion",
".",
"PyRegion",
".",
"setParameter",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L278-L314 | [
"def",
"setParameter",
"(",
"self",
",",
"name",
",",
"index",
",",
"value",
")",
":",
"if",
"name",
"==",
"\"trainRecords\"",
":",
"# Ensure that the trainRecords can only be set to minimum of the ROWID in",
"# the saved states",
"if",
"not",
"(",
"isinstance",
"(",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion.compute | Process one input sample.
This method is called by the runtime engine. | src/nupic/regions/knn_anomaly_classifier_region.py | def compute(self, inputs, outputs):
"""
Process one input sample.
This method is called by the runtime engine.
"""
record = self._constructClassificationRecord(inputs)
#Classify this point after waiting the classification delay
if record.ROWID >= self.getParameter('trainRecords'):
sel... | def compute(self, inputs, outputs):
"""
Process one input sample.
This method is called by the runtime engine.
"""
record = self._constructClassificationRecord(inputs)
#Classify this point after waiting the classification delay
if record.ROWID >= self.getParameter('trainRecords'):
sel... | [
"Process",
"one",
"input",
"sample",
".",
"This",
"method",
"is",
"called",
"by",
"the",
"runtime",
"engine",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L317-L335 | [
"def",
"compute",
"(",
"self",
",",
"inputs",
",",
"outputs",
")",
":",
"record",
"=",
"self",
".",
"_constructClassificationRecord",
"(",
"inputs",
")",
"#Classify this point after waiting the classification delay",
"if",
"record",
".",
"ROWID",
">=",
"self",
".",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion._classifyState | Reclassifies given state. | src/nupic/regions/knn_anomaly_classifier_region.py | def _classifyState(self, state):
"""
Reclassifies given state.
"""
# Record is before wait period do not classifiy
if state.ROWID < self.getParameter('trainRecords'):
if not state.setByUser:
state.anomalyLabel = []
self._deleteRecordsFromKNN([state])
return
label = K... | def _classifyState(self, state):
"""
Reclassifies given state.
"""
# Record is before wait period do not classifiy
if state.ROWID < self.getParameter('trainRecords'):
if not state.setByUser:
state.anomalyLabel = []
self._deleteRecordsFromKNN([state])
return
label = K... | [
"Reclassifies",
"given",
"state",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L355-L405 | [
"def",
"_classifyState",
"(",
"self",
",",
"state",
")",
":",
"# Record is before wait period do not classifiy",
"if",
"state",
".",
"ROWID",
"<",
"self",
".",
"getParameter",
"(",
"'trainRecords'",
")",
":",
"if",
"not",
"state",
".",
"setByUser",
":",
"state",... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion._constructClassificationRecord | Construct a _HTMClassificationRecord based on the state of the model
passed in through the inputs.
Types for self.classificationVectorType:
1 - TM active cells in learn state
2 - SP columns concatenated with error from TM column predictions and SP | src/nupic/regions/knn_anomaly_classifier_region.py | def _constructClassificationRecord(self, inputs):
"""
Construct a _HTMClassificationRecord based on the state of the model
passed in through the inputs.
Types for self.classificationVectorType:
1 - TM active cells in learn state
2 - SP columns concatenated with error from TM column predicti... | def _constructClassificationRecord(self, inputs):
"""
Construct a _HTMClassificationRecord based on the state of the model
passed in through the inputs.
Types for self.classificationVectorType:
1 - TM active cells in learn state
2 - SP columns concatenated with error from TM column predicti... | [
"Construct",
"a",
"_HTMClassificationRecord",
"based",
"on",
"the",
"state",
"of",
"the",
"model",
"passed",
"in",
"through",
"the",
"inputs",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L408-L470 | [
"def",
"_constructClassificationRecord",
"(",
"self",
",",
"inputs",
")",
":",
"# Count the number of unpredicted columns",
"allSPColumns",
"=",
"inputs",
"[",
"\"spBottomUpOut\"",
"]",
"activeSPColumns",
"=",
"allSPColumns",
".",
"nonzero",
"(",
")",
"[",
"0",
"]",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion._addRecordToKNN | Adds the record to the KNN classifier. | src/nupic/regions/knn_anomaly_classifier_region.py | def _addRecordToKNN(self, record):
"""
Adds the record to the KNN classifier.
"""
knn = self._knnclassifier._knn
prototype_idx = self._knnclassifier.getParameter('categoryRecencyList')
category = self._labelListToCategoryNumber(record.anomalyLabel)
# If record is already in the classifier,... | def _addRecordToKNN(self, record):
"""
Adds the record to the KNN classifier.
"""
knn = self._knnclassifier._knn
prototype_idx = self._knnclassifier.getParameter('categoryRecencyList')
category = self._labelListToCategoryNumber(record.anomalyLabel)
# If record is already in the classifier,... | [
"Adds",
"the",
"record",
"to",
"the",
"KNN",
"classifier",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L473-L490 | [
"def",
"_addRecordToKNN",
"(",
"self",
",",
"record",
")",
":",
"knn",
"=",
"self",
".",
"_knnclassifier",
".",
"_knn",
"prototype_idx",
"=",
"self",
".",
"_knnclassifier",
".",
"getParameter",
"(",
"'categoryRecencyList'",
")",
"category",
"=",
"self",
".",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion._deleteRecordsFromKNN | Removes the given records from the classifier.
parameters
------------
recordsToDelete - list of records to delete from the classififier | src/nupic/regions/knn_anomaly_classifier_region.py | def _deleteRecordsFromKNN(self, recordsToDelete):
"""
Removes the given records from the classifier.
parameters
------------
recordsToDelete - list of records to delete from the classififier
"""
prototype_idx = self._knnclassifier.getParameter('categoryRecencyList')
idsToDelete = ([r.R... | def _deleteRecordsFromKNN(self, recordsToDelete):
"""
Removes the given records from the classifier.
parameters
------------
recordsToDelete - list of records to delete from the classififier
"""
prototype_idx = self._knnclassifier.getParameter('categoryRecencyList')
idsToDelete = ([r.R... | [
"Removes",
"the",
"given",
"records",
"from",
"the",
"classifier",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L494-L509 | [
"def",
"_deleteRecordsFromKNN",
"(",
"self",
",",
"recordsToDelete",
")",
":",
"prototype_idx",
"=",
"self",
".",
"_knnclassifier",
".",
"getParameter",
"(",
"'categoryRecencyList'",
")",
"idsToDelete",
"=",
"(",
"[",
"r",
".",
"ROWID",
"for",
"r",
"in",
"reco... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion._deleteRangeFromKNN | Removes any stored records within the range from start to
end. Noninclusive of end.
parameters
------------
start - integer representing the ROWID of the start of the deletion range,
end - integer representing the ROWID of the end of the deletion range,
if None, it will default to end. | src/nupic/regions/knn_anomaly_classifier_region.py | def _deleteRangeFromKNN(self, start=0, end=None):
"""
Removes any stored records within the range from start to
end. Noninclusive of end.
parameters
------------
start - integer representing the ROWID of the start of the deletion range,
end - integer representing the ROWID of the end of the... | def _deleteRangeFromKNN(self, start=0, end=None):
"""
Removes any stored records within the range from start to
end. Noninclusive of end.
parameters
------------
start - integer representing the ROWID of the start of the deletion range,
end - integer representing the ROWID of the end of the... | [
"Removes",
"any",
"stored",
"records",
"within",
"the",
"range",
"from",
"start",
"to",
"end",
".",
"Noninclusive",
"of",
"end",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L512-L535 | [
"def",
"_deleteRangeFromKNN",
"(",
"self",
",",
"start",
"=",
"0",
",",
"end",
"=",
"None",
")",
":",
"prototype_idx",
"=",
"numpy",
".",
"array",
"(",
"self",
".",
"_knnclassifier",
".",
"getParameter",
"(",
"'categoryRecencyList'",
")",
")",
"if",
"end",... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion._recomputeRecordFromKNN | returns the classified labeling of record | src/nupic/regions/knn_anomaly_classifier_region.py | def _recomputeRecordFromKNN(self, record):
"""
returns the classified labeling of record
"""
inputs = {
"categoryIn": [None],
"bottomUpIn": self._getStateAnomalyVector(record),
}
outputs = {"categoriesOut": numpy.zeros((1,)),
"bestPrototypeIndices":numpy.zeros((1,)),
... | def _recomputeRecordFromKNN(self, record):
"""
returns the classified labeling of record
"""
inputs = {
"categoryIn": [None],
"bottomUpIn": self._getStateAnomalyVector(record),
}
outputs = {"categoriesOut": numpy.zeros((1,)),
"bestPrototypeIndices":numpy.zeros((1,)),
... | [
"returns",
"the",
"classified",
"labeling",
"of",
"record"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L538-L575 | [
"def",
"_recomputeRecordFromKNN",
"(",
"self",
",",
"record",
")",
":",
"inputs",
"=",
"{",
"\"categoryIn\"",
":",
"[",
"None",
"]",
",",
"\"bottomUpIn\"",
":",
"self",
".",
"_getStateAnomalyVector",
"(",
"record",
")",
",",
"}",
"outputs",
"=",
"{",
"\"ca... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion._labelToCategoryNumber | Since the KNN Classifier stores categories as numbers, we must store each
label as a number. This method converts from a label to a unique number.
Each label is assigned a unique bit so multiple labels may be assigned to
a single record. | src/nupic/regions/knn_anomaly_classifier_region.py | def _labelToCategoryNumber(self, label):
"""
Since the KNN Classifier stores categories as numbers, we must store each
label as a number. This method converts from a label to a unique number.
Each label is assigned a unique bit so multiple labels may be assigned to
a single record.
"""
if la... | def _labelToCategoryNumber(self, label):
"""
Since the KNN Classifier stores categories as numbers, we must store each
label as a number. This method converts from a label to a unique number.
Each label is assigned a unique bit so multiple labels may be assigned to
a single record.
"""
if la... | [
"Since",
"the",
"KNN",
"Classifier",
"stores",
"categories",
"as",
"numbers",
"we",
"must",
"store",
"each",
"label",
"as",
"a",
"number",
".",
"This",
"method",
"converts",
"from",
"a",
"label",
"to",
"a",
"unique",
"number",
".",
"Each",
"label",
"is",
... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L578-L587 | [
"def",
"_labelToCategoryNumber",
"(",
"self",
",",
"label",
")",
":",
"if",
"label",
"not",
"in",
"self",
".",
"saved_categories",
":",
"self",
".",
"saved_categories",
".",
"append",
"(",
"label",
")",
"return",
"pow",
"(",
"2",
",",
"self",
".",
"saved... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion._labelListToCategoryNumber | This method takes a list of labels and returns a unique category number.
This enables this class to store a list of categories for each point since
the KNN classifier only stores a single number category for each record. | src/nupic/regions/knn_anomaly_classifier_region.py | def _labelListToCategoryNumber(self, labelList):
"""
This method takes a list of labels and returns a unique category number.
This enables this class to store a list of categories for each point since
the KNN classifier only stores a single number category for each record.
"""
categoryNumber = 0... | def _labelListToCategoryNumber(self, labelList):
"""
This method takes a list of labels and returns a unique category number.
This enables this class to store a list of categories for each point since
the KNN classifier only stores a single number category for each record.
"""
categoryNumber = 0... | [
"This",
"method",
"takes",
"a",
"list",
"of",
"labels",
"and",
"returns",
"a",
"unique",
"category",
"number",
".",
"This",
"enables",
"this",
"class",
"to",
"store",
"a",
"list",
"of",
"categories",
"for",
"each",
"point",
"since",
"the",
"KNN",
"classifi... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L589-L598 | [
"def",
"_labelListToCategoryNumber",
"(",
"self",
",",
"labelList",
")",
":",
"categoryNumber",
"=",
"0",
"for",
"label",
"in",
"labelList",
":",
"categoryNumber",
"+=",
"self",
".",
"_labelToCategoryNumber",
"(",
"label",
")",
"return",
"categoryNumber"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion._categoryToLabelList | Converts a category number into a list of labels | src/nupic/regions/knn_anomaly_classifier_region.py | def _categoryToLabelList(self, category):
"""
Converts a category number into a list of labels
"""
if category is None:
return []
labelList = []
labelNum = 0
while category > 0:
if category % 2 == 1:
labelList.append(self.saved_categories[labelNum])
labelNum += 1
... | def _categoryToLabelList(self, category):
"""
Converts a category number into a list of labels
"""
if category is None:
return []
labelList = []
labelNum = 0
while category > 0:
if category % 2 == 1:
labelList.append(self.saved_categories[labelNum])
labelNum += 1
... | [
"Converts",
"a",
"category",
"number",
"into",
"a",
"list",
"of",
"labels"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L601-L615 | [
"def",
"_categoryToLabelList",
"(",
"self",
",",
"category",
")",
":",
"if",
"category",
"is",
"None",
":",
"return",
"[",
"]",
"labelList",
"=",
"[",
"]",
"labelNum",
"=",
"0",
"while",
"category",
">",
"0",
":",
"if",
"category",
"%",
"2",
"==",
"1... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion._getStateAnomalyVector | Returns a state's anomaly vertor converting it from spare to dense | src/nupic/regions/knn_anomaly_classifier_region.py | def _getStateAnomalyVector(self, state):
"""
Returns a state's anomaly vertor converting it from spare to dense
"""
vector = numpy.zeros(self._anomalyVectorLength)
vector[state.anomalyVector] = 1
return vector | def _getStateAnomalyVector(self, state):
"""
Returns a state's anomaly vertor converting it from spare to dense
"""
vector = numpy.zeros(self._anomalyVectorLength)
vector[state.anomalyVector] = 1
return vector | [
"Returns",
"a",
"state",
"s",
"anomaly",
"vertor",
"converting",
"it",
"from",
"spare",
"to",
"dense"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L618-L624 | [
"def",
"_getStateAnomalyVector",
"(",
"self",
",",
"state",
")",
":",
"vector",
"=",
"numpy",
".",
"zeros",
"(",
"self",
".",
"_anomalyVectorLength",
")",
"vector",
"[",
"state",
".",
"anomalyVector",
"]",
"=",
"1",
"return",
"vector"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion.getLabels | Get the labels on classified points within range start to end. Not inclusive
of end.
:returns: (dict) with format:
::
{
'isProcessing': boolean,
'recordLabels': list of results
}
``isProcessing`` - currently always false as recalculation blocks; used if
... | src/nupic/regions/knn_anomaly_classifier_region.py | def getLabels(self, start=None, end=None):
"""
Get the labels on classified points within range start to end. Not inclusive
of end.
:returns: (dict) with format:
::
{
'isProcessing': boolean,
'recordLabels': list of results
}
``isProcessing`` - current... | def getLabels(self, start=None, end=None):
"""
Get the labels on classified points within range start to end. Not inclusive
of end.
:returns: (dict) with format:
::
{
'isProcessing': boolean,
'recordLabels': list of results
}
``isProcessing`` - current... | [
"Get",
"the",
"labels",
"on",
"classified",
"points",
"within",
"range",
"start",
"to",
"end",
".",
"Not",
"inclusive",
"of",
"end",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L627-L694 | [
"def",
"getLabels",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"if",
"len",
"(",
"self",
".",
"_recordsCache",
")",
"==",
"0",
":",
"return",
"{",
"'isProcessing'",
":",
"False",
",",
"'recordLabels'",
":",
"[",
"]",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion.addLabel | Add the label labelName to each record with record ROWID in range from
``start`` to ``end``, noninclusive of end.
This will recalculate all points from end to the last record stored in the
internal cache of this classifier.
:param start: (int) start index
:param end: (int) end index (noninclusive... | src/nupic/regions/knn_anomaly_classifier_region.py | def addLabel(self, start, end, labelName):
"""
Add the label labelName to each record with record ROWID in range from
``start`` to ``end``, noninclusive of end.
This will recalculate all points from end to the last record stored in the
internal cache of this classifier.
:param start: (int) sta... | def addLabel(self, start, end, labelName):
"""
Add the label labelName to each record with record ROWID in range from
``start`` to ``end``, noninclusive of end.
This will recalculate all points from end to the last record stored in the
internal cache of this classifier.
:param start: (int) sta... | [
"Add",
"the",
"label",
"labelName",
"to",
"each",
"record",
"with",
"record",
"ROWID",
"in",
"range",
"from",
"start",
"to",
"end",
"noninclusive",
"of",
"end",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L697-L757 | [
"def",
"addLabel",
"(",
"self",
",",
"start",
",",
"end",
",",
"labelName",
")",
":",
"if",
"len",
"(",
"self",
".",
"_recordsCache",
")",
"==",
"0",
":",
"raise",
"HTMPredictionModelInvalidRangeError",
"(",
"\"Invalid supplied range for 'addLabel'. \"",
"\"Model ... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | KNNAnomalyClassifierRegion.removeLabels | Remove labels from each record with record ROWID in range from
``start`` to ``end``, noninclusive of end. Removes all records if
``labelFilter`` is None, otherwise only removes the labels equal to
``labelFilter``.
This will recalculate all points from end to the last record stored in the
internal... | src/nupic/regions/knn_anomaly_classifier_region.py | def removeLabels(self, start=None, end=None, labelFilter=None):
"""
Remove labels from each record with record ROWID in range from
``start`` to ``end``, noninclusive of end. Removes all records if
``labelFilter`` is None, otherwise only removes the labels equal to
``labelFilter``.
This will r... | def removeLabels(self, start=None, end=None, labelFilter=None):
"""
Remove labels from each record with record ROWID in range from
``start`` to ``end``, noninclusive of end. Removes all records if
``labelFilter`` is None, otherwise only removes the labels equal to
``labelFilter``.
This will r... | [
"Remove",
"labels",
"from",
"each",
"record",
"with",
"record",
"ROWID",
"in",
"range",
"from",
"start",
"to",
"end",
"noninclusive",
"of",
"end",
".",
"Removes",
"all",
"records",
"if",
"labelFilter",
"is",
"None",
"otherwise",
"only",
"removes",
"the",
"la... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/knn_anomaly_classifier_region.py#L760-L829 | [
"def",
"removeLabels",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"labelFilter",
"=",
"None",
")",
":",
"if",
"len",
"(",
"self",
".",
"_recordsCache",
")",
"==",
"0",
":",
"raise",
"HTMPredictionModelInvalidRangeError",
"(",
"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | CategoryFilter.match | Returns True if the record matches any of the provided filters | src/nupic/data/category_filter.py | def match(self, record):
'''
Returns True if the record matches any of the provided filters
'''
for field, meta in self.filterDict.iteritems():
index = meta['index']
categories = meta['categories']
for category in categories:
# Record might be blank, handle this
if not... | def match(self, record):
'''
Returns True if the record matches any of the provided filters
'''
for field, meta in self.filterDict.iteritems():
index = meta['index']
categories = meta['categories']
for category in categories:
# Record might be blank, handle this
if not... | [
"Returns",
"True",
"if",
"the",
"record",
"matches",
"any",
"of",
"the",
"provided",
"filters"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/category_filter.py#L58-L78 | [
"def",
"match",
"(",
"self",
",",
"record",
")",
":",
"for",
"field",
",",
"meta",
"in",
"self",
".",
"filterDict",
".",
"iteritems",
"(",
")",
":",
"index",
"=",
"meta",
"[",
"'index'",
"]",
"categories",
"=",
"meta",
"[",
"'categories'",
"]",
"for"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _SparseMatrixCorticalColumnAdapter.replace | Wraps replaceSparseRow() | src/nupic/algorithms/spatial_pooler.py | def replace(self, columnIndex, bitmap):
""" Wraps replaceSparseRow()"""
return super(_SparseMatrixCorticalColumnAdapter, self).replaceSparseRow(
columnIndex, bitmap
) | def replace(self, columnIndex, bitmap):
""" Wraps replaceSparseRow()"""
return super(_SparseMatrixCorticalColumnAdapter, self).replaceSparseRow(
columnIndex, bitmap
) | [
"Wraps",
"replaceSparseRow",
"()"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L67-L71 | [
"def",
"replace",
"(",
"self",
",",
"columnIndex",
",",
"bitmap",
")",
":",
"return",
"super",
"(",
"_SparseMatrixCorticalColumnAdapter",
",",
"self",
")",
".",
"replaceSparseRow",
"(",
"columnIndex",
",",
"bitmap",
")"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _SparseMatrixCorticalColumnAdapter.update | Wraps setRowFromDense() | src/nupic/algorithms/spatial_pooler.py | def update(self, columnIndex, vector):
""" Wraps setRowFromDense()"""
return super(_SparseMatrixCorticalColumnAdapter, self).setRowFromDense(
columnIndex, vector
) | def update(self, columnIndex, vector):
""" Wraps setRowFromDense()"""
return super(_SparseMatrixCorticalColumnAdapter, self).setRowFromDense(
columnIndex, vector
) | [
"Wraps",
"setRowFromDense",
"()"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L74-L78 | [
"def",
"update",
"(",
"self",
",",
"columnIndex",
",",
"vector",
")",
":",
"return",
"super",
"(",
"_SparseMatrixCorticalColumnAdapter",
",",
"self",
")",
".",
"setRowFromDense",
"(",
"columnIndex",
",",
"vector",
")"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler.setLocalAreaDensity | Sets the local area density. Invalidates the 'numActiveColumnsPerInhArea'
parameter
:param localAreaDensity: (float) value to set | src/nupic/algorithms/spatial_pooler.py | def setLocalAreaDensity(self, localAreaDensity):
"""
Sets the local area density. Invalidates the 'numActiveColumnsPerInhArea'
parameter
:param localAreaDensity: (float) value to set
"""
assert(localAreaDensity > 0 and localAreaDensity <= 1)
self._localAreaDensity = localAreaDensity
... | def setLocalAreaDensity(self, localAreaDensity):
"""
Sets the local area density. Invalidates the 'numActiveColumnsPerInhArea'
parameter
:param localAreaDensity: (float) value to set
"""
assert(localAreaDensity > 0 and localAreaDensity <= 1)
self._localAreaDensity = localAreaDensity
... | [
"Sets",
"the",
"local",
"area",
"density",
".",
"Invalidates",
"the",
"numActiveColumnsPerInhArea",
"parameter",
":",
"param",
"localAreaDensity",
":",
"(",
"float",
")",
"value",
"to",
"set"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L487-L496 | [
"def",
"setLocalAreaDensity",
"(",
"self",
",",
"localAreaDensity",
")",
":",
"assert",
"(",
"localAreaDensity",
">",
"0",
"and",
"localAreaDensity",
"<=",
"1",
")",
"self",
".",
"_localAreaDensity",
"=",
"localAreaDensity",
"self",
".",
"_numActiveColumnsPerInhArea... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler.getPotential | :param columnIndex: (int) column index to get potential for.
:param potential: (list) will be overwritten with column potentials. Must
match the number of inputs. | src/nupic/algorithms/spatial_pooler.py | def getPotential(self, columnIndex, potential):
"""
:param columnIndex: (int) column index to get potential for.
:param potential: (list) will be overwritten with column potentials. Must
match the number of inputs.
"""
assert(columnIndex < self._numColumns)
potential[:] = self._poten... | def getPotential(self, columnIndex, potential):
"""
:param columnIndex: (int) column index to get potential for.
:param potential: (list) will be overwritten with column potentials. Must
match the number of inputs.
"""
assert(columnIndex < self._numColumns)
potential[:] = self._poten... | [
":",
"param",
"columnIndex",
":",
"(",
"int",
")",
"column",
"index",
"to",
"get",
"potential",
"for",
".",
":",
"param",
"potential",
":",
"(",
"list",
")",
"will",
"be",
"overwritten",
"with",
"column",
"potentials",
".",
"Must",
"match",
"the",
"numbe... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L792-L799 | [
"def",
"getPotential",
"(",
"self",
",",
"columnIndex",
",",
"potential",
")",
":",
"assert",
"(",
"columnIndex",
"<",
"self",
".",
"_numColumns",
")",
"potential",
"[",
":",
"]",
"=",
"self",
".",
"_potentialPools",
"[",
"columnIndex",
"]"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler.setPotential | Sets the potential mapping for a given column. ``potential`` size must match
the number of inputs, and must be greater than ``stimulusThreshold``.
:param columnIndex: (int) column index to set potential for.
:param potential: (list) value to set. | src/nupic/algorithms/spatial_pooler.py | def setPotential(self, columnIndex, potential):
"""
Sets the potential mapping for a given column. ``potential`` size must match
the number of inputs, and must be greater than ``stimulusThreshold``.
:param columnIndex: (int) column index to set potential for.
:param potential: (list) value to ... | def setPotential(self, columnIndex, potential):
"""
Sets the potential mapping for a given column. ``potential`` size must match
the number of inputs, and must be greater than ``stimulusThreshold``.
:param columnIndex: (int) column index to set potential for.
:param potential: (list) value to ... | [
"Sets",
"the",
"potential",
"mapping",
"for",
"a",
"given",
"column",
".",
"potential",
"size",
"must",
"match",
"the",
"number",
"of",
"inputs",
"and",
"must",
"be",
"greater",
"than",
"stimulusThreshold",
".",
":",
"param",
"columnIndex",
":",
"(",
"int",
... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L802-L818 | [
"def",
"setPotential",
"(",
"self",
",",
"columnIndex",
",",
"potential",
")",
":",
"assert",
"(",
"columnIndex",
"<",
"self",
".",
"_numColumns",
")",
"potentialSparse",
"=",
"numpy",
".",
"where",
"(",
"potential",
">",
"0",
")",
"[",
"0",
"]",
"if",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler.getPermanence | Returns the permanence values for a given column. ``permanence`` size
must match the number of inputs.
:param columnIndex: (int) column index to get permanence for.
:param permanence: (list) will be overwritten with permanences. | src/nupic/algorithms/spatial_pooler.py | def getPermanence(self, columnIndex, permanence):
"""
Returns the permanence values for a given column. ``permanence`` size
must match the number of inputs.
:param columnIndex: (int) column index to get permanence for.
:param permanence: (list) will be overwritten with permanences.
"""
... | def getPermanence(self, columnIndex, permanence):
"""
Returns the permanence values for a given column. ``permanence`` size
must match the number of inputs.
:param columnIndex: (int) column index to get permanence for.
:param permanence: (list) will be overwritten with permanences.
"""
... | [
"Returns",
"the",
"permanence",
"values",
"for",
"a",
"given",
"column",
".",
"permanence",
"size",
"must",
"match",
"the",
"number",
"of",
"inputs",
".",
":",
"param",
"columnIndex",
":",
"(",
"int",
")",
"column",
"index",
"to",
"get",
"permanence",
"for... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L821-L830 | [
"def",
"getPermanence",
"(",
"self",
",",
"columnIndex",
",",
"permanence",
")",
":",
"assert",
"(",
"columnIndex",
"<",
"self",
".",
"_numColumns",
")",
"permanence",
"[",
":",
"]",
"=",
"self",
".",
"_permanences",
"[",
"columnIndex",
"]"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler.setPermanence | Sets the permanence values for a given column. ``permanence`` size must
match the number of inputs.
:param columnIndex: (int) column index to set permanence for.
:param permanence: (list) value to set. | src/nupic/algorithms/spatial_pooler.py | def setPermanence(self, columnIndex, permanence):
"""
Sets the permanence values for a given column. ``permanence`` size must
match the number of inputs.
:param columnIndex: (int) column index to set permanence for.
:param permanence: (list) value to set.
"""
assert(columnIndex < self... | def setPermanence(self, columnIndex, permanence):
"""
Sets the permanence values for a given column. ``permanence`` size must
match the number of inputs.
:param columnIndex: (int) column index to set permanence for.
:param permanence: (list) value to set.
"""
assert(columnIndex < self... | [
"Sets",
"the",
"permanence",
"values",
"for",
"a",
"given",
"column",
".",
"permanence",
"size",
"must",
"match",
"the",
"number",
"of",
"inputs",
".",
":",
"param",
"columnIndex",
":",
"(",
"int",
")",
"column",
"index",
"to",
"set",
"permanence",
"for",
... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L833-L842 | [
"def",
"setPermanence",
"(",
"self",
",",
"columnIndex",
",",
"permanence",
")",
":",
"assert",
"(",
"columnIndex",
"<",
"self",
".",
"_numColumns",
")",
"self",
".",
"_updatePermanencesForColumn",
"(",
"permanence",
",",
"columnIndex",
",",
"raisePerm",
"=",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler.getConnectedSynapses | :param connectedSynapses: (list) will be overwritten
:returns: (iter) the connected synapses for a given column.
``connectedSynapses`` size must match the number of inputs | src/nupic/algorithms/spatial_pooler.py | def getConnectedSynapses(self, columnIndex, connectedSynapses):
"""
:param connectedSynapses: (list) will be overwritten
:returns: (iter) the connected synapses for a given column.
``connectedSynapses`` size must match the number of inputs"""
assert(columnIndex < self._numColumns)
conn... | def getConnectedSynapses(self, columnIndex, connectedSynapses):
"""
:param connectedSynapses: (list) will be overwritten
:returns: (iter) the connected synapses for a given column.
``connectedSynapses`` size must match the number of inputs"""
assert(columnIndex < self._numColumns)
conn... | [
":",
"param",
"connectedSynapses",
":",
"(",
"list",
")",
"will",
"be",
"overwritten",
":",
"returns",
":",
"(",
"iter",
")",
"the",
"connected",
"synapses",
"for",
"a",
"given",
"column",
".",
"connectedSynapses",
"size",
"must",
"match",
"the",
"number",
... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L845-L851 | [
"def",
"getConnectedSynapses",
"(",
"self",
",",
"columnIndex",
",",
"connectedSynapses",
")",
":",
"assert",
"(",
"columnIndex",
"<",
"self",
".",
"_numColumns",
")",
"connectedSynapses",
"[",
":",
"]",
"=",
"self",
".",
"_connectedSynapses",
"[",
"columnIndex"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler.stripUnlearnedColumns | Removes the set of columns who have never been active from the set of
active columns selected in the inhibition round. Such columns cannot
represent learned pattern and are therefore meaningless if only inference
is required. This should not be done when using a random, unlearned SP
since you would end ... | src/nupic/algorithms/spatial_pooler.py | def stripUnlearnedColumns(self, activeArray):
"""
Removes the set of columns who have never been active from the set of
active columns selected in the inhibition round. Such columns cannot
represent learned pattern and are therefore meaningless if only inference
is required. This should not be done ... | def stripUnlearnedColumns(self, activeArray):
"""
Removes the set of columns who have never been active from the set of
active columns selected in the inhibition round. Such columns cannot
represent learned pattern and are therefore meaningless if only inference
is required. This should not be done ... | [
"Removes",
"the",
"set",
"of",
"columns",
"who",
"have",
"never",
"been",
"active",
"from",
"the",
"set",
"of",
"active",
"columns",
"selected",
"in",
"the",
"inhibition",
"round",
".",
"Such",
"columns",
"cannot",
"represent",
"learned",
"pattern",
"and",
"... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L937-L951 | [
"def",
"stripUnlearnedColumns",
"(",
"self",
",",
"activeArray",
")",
":",
"neverLearned",
"=",
"numpy",
".",
"where",
"(",
"self",
".",
"_activeDutyCycles",
"==",
"0",
")",
"[",
"0",
"]",
"activeArray",
"[",
"neverLearned",
"]",
"=",
"0"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._updateMinDutyCycles | Updates the minimum duty cycles defining normal activity for a column. A
column with activity duty cycle below this minimum threshold is boosted. | src/nupic/algorithms/spatial_pooler.py | def _updateMinDutyCycles(self):
"""
Updates the minimum duty cycles defining normal activity for a column. A
column with activity duty cycle below this minimum threshold is boosted.
"""
if self._globalInhibition or self._inhibitionRadius > self._numInputs:
self._updateMinDutyCyclesGlobal()
... | def _updateMinDutyCycles(self):
"""
Updates the minimum duty cycles defining normal activity for a column. A
column with activity duty cycle below this minimum threshold is boosted.
"""
if self._globalInhibition or self._inhibitionRadius > self._numInputs:
self._updateMinDutyCyclesGlobal()
... | [
"Updates",
"the",
"minimum",
"duty",
"cycles",
"defining",
"normal",
"activity",
"for",
"a",
"column",
".",
"A",
"column",
"with",
"activity",
"duty",
"cycle",
"below",
"this",
"minimum",
"threshold",
"is",
"boosted",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L954-L962 | [
"def",
"_updateMinDutyCycles",
"(",
"self",
")",
":",
"if",
"self",
".",
"_globalInhibition",
"or",
"self",
".",
"_inhibitionRadius",
">",
"self",
".",
"_numInputs",
":",
"self",
".",
"_updateMinDutyCyclesGlobal",
"(",
")",
"else",
":",
"self",
".",
"_updateMi... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._updateMinDutyCyclesGlobal | Updates the minimum duty cycles in a global fashion. Sets the minimum duty
cycles for the overlap all columns to be a percent of the maximum in the
region, specified by minPctOverlapDutyCycle. Functionality it is equivalent
to _updateMinDutyCyclesLocal, but this function exploits the globality of
the co... | src/nupic/algorithms/spatial_pooler.py | def _updateMinDutyCyclesGlobal(self):
"""
Updates the minimum duty cycles in a global fashion. Sets the minimum duty
cycles for the overlap all columns to be a percent of the maximum in the
region, specified by minPctOverlapDutyCycle. Functionality it is equivalent
to _updateMinDutyCyclesLocal, but ... | def _updateMinDutyCyclesGlobal(self):
"""
Updates the minimum duty cycles in a global fashion. Sets the minimum duty
cycles for the overlap all columns to be a percent of the maximum in the
region, specified by minPctOverlapDutyCycle. Functionality it is equivalent
to _updateMinDutyCyclesLocal, but ... | [
"Updates",
"the",
"minimum",
"duty",
"cycles",
"in",
"a",
"global",
"fashion",
".",
"Sets",
"the",
"minimum",
"duty",
"cycles",
"for",
"the",
"overlap",
"all",
"columns",
"to",
"be",
"a",
"percent",
"of",
"the",
"maximum",
"in",
"the",
"region",
"specified... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L965-L975 | [
"def",
"_updateMinDutyCyclesGlobal",
"(",
"self",
")",
":",
"self",
".",
"_minOverlapDutyCycles",
".",
"fill",
"(",
"self",
".",
"_minPctOverlapDutyCycles",
"*",
"self",
".",
"_overlapDutyCycles",
".",
"max",
"(",
")",
")"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._updateMinDutyCyclesLocal | Updates the minimum duty cycles. The minimum duty cycles are determined
locally. Each column's minimum duty cycles are set to be a percent of the
maximum duty cycles in the column's neighborhood. Unlike
_updateMinDutyCyclesGlobal, here the values can be quite different for
different columns. | src/nupic/algorithms/spatial_pooler.py | def _updateMinDutyCyclesLocal(self):
"""
Updates the minimum duty cycles. The minimum duty cycles are determined
locally. Each column's minimum duty cycles are set to be a percent of the
maximum duty cycles in the column's neighborhood. Unlike
_updateMinDutyCyclesGlobal, here the values can be quite... | def _updateMinDutyCyclesLocal(self):
"""
Updates the minimum duty cycles. The minimum duty cycles are determined
locally. Each column's minimum duty cycles are set to be a percent of the
maximum duty cycles in the column's neighborhood. Unlike
_updateMinDutyCyclesGlobal, here the values can be quite... | [
"Updates",
"the",
"minimum",
"duty",
"cycles",
".",
"The",
"minimum",
"duty",
"cycles",
"are",
"determined",
"locally",
".",
"Each",
"column",
"s",
"minimum",
"duty",
"cycles",
"are",
"set",
"to",
"be",
"a",
"percent",
"of",
"the",
"maximum",
"duty",
"cycl... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L978-L993 | [
"def",
"_updateMinDutyCyclesLocal",
"(",
"self",
")",
":",
"for",
"column",
"in",
"xrange",
"(",
"self",
".",
"_numColumns",
")",
":",
"neighborhood",
"=",
"self",
".",
"_getColumnNeighborhood",
"(",
"column",
")",
"maxActiveDuty",
"=",
"self",
".",
"_activeDu... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._updateDutyCycles | Updates the duty cycles for each column. The OVERLAP duty cycle is a moving
average of the number of inputs which overlapped with the each column. The
ACTIVITY duty cycles is a moving average of the frequency of activation for
each column.
Parameters:
----------------------------
:param overlap... | src/nupic/algorithms/spatial_pooler.py | def _updateDutyCycles(self, overlaps, activeColumns):
"""
Updates the duty cycles for each column. The OVERLAP duty cycle is a moving
average of the number of inputs which overlapped with the each column. The
ACTIVITY duty cycles is a moving average of the frequency of activation for
each column.
... | def _updateDutyCycles(self, overlaps, activeColumns):
"""
Updates the duty cycles for each column. The OVERLAP duty cycle is a moving
average of the number of inputs which overlapped with the each column. The
ACTIVITY duty cycles is a moving average of the frequency of activation for
each column.
... | [
"Updates",
"the",
"duty",
"cycles",
"for",
"each",
"column",
".",
"The",
"OVERLAP",
"duty",
"cycle",
"is",
"a",
"moving",
"average",
"of",
"the",
"number",
"of",
"inputs",
"which",
"overlapped",
"with",
"the",
"each",
"column",
".",
"The",
"ACTIVITY",
"dut... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L996-L1033 | [
"def",
"_updateDutyCycles",
"(",
"self",
",",
"overlaps",
",",
"activeColumns",
")",
":",
"overlapArray",
"=",
"numpy",
".",
"zeros",
"(",
"self",
".",
"_numColumns",
",",
"dtype",
"=",
"realDType",
")",
"activeArray",
"=",
"numpy",
".",
"zeros",
"(",
"sel... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._updateInhibitionRadius | Update the inhibition radius. The inhibition radius is a measure of the
square (or hypersquare) of columns that each a column is "connected to"
on average. Since columns are are not connected to each other directly, we
determine this quantity by first figuring out how many *inputs* a column is
connected... | src/nupic/algorithms/spatial_pooler.py | def _updateInhibitionRadius(self):
"""
Update the inhibition radius. The inhibition radius is a measure of the
square (or hypersquare) of columns that each a column is "connected to"
on average. Since columns are are not connected to each other directly, we
determine this quantity by first figuring ... | def _updateInhibitionRadius(self):
"""
Update the inhibition radius. The inhibition radius is a measure of the
square (or hypersquare) of columns that each a column is "connected to"
on average. Since columns are are not connected to each other directly, we
determine this quantity by first figuring ... | [
"Update",
"the",
"inhibition",
"radius",
".",
"The",
"inhibition",
"radius",
"is",
"a",
"measure",
"of",
"the",
"square",
"(",
"or",
"hypersquare",
")",
"of",
"columns",
"that",
"each",
"a",
"column",
"is",
"connected",
"to",
"on",
"average",
".",
"Since",... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1036-L1059 | [
"def",
"_updateInhibitionRadius",
"(",
"self",
")",
":",
"if",
"self",
".",
"_globalInhibition",
":",
"self",
".",
"_inhibitionRadius",
"=",
"int",
"(",
"self",
".",
"_columnDimensions",
".",
"max",
"(",
")",
")",
"return",
"avgConnectedSpan",
"=",
"numpy",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._avgColumnsPerInput | The average number of columns per input, taking into account the topology
of the inputs and columns. This value is used to calculate the inhibition
radius. This function supports an arbitrary number of dimensions. If the
number of column dimensions does not match the number of input dimensions,
we treat... | src/nupic/algorithms/spatial_pooler.py | def _avgColumnsPerInput(self):
"""
The average number of columns per input, taking into account the topology
of the inputs and columns. This value is used to calculate the inhibition
radius. This function supports an arbitrary number of dimensions. If the
number of column dimensions does not match t... | def _avgColumnsPerInput(self):
"""
The average number of columns per input, taking into account the topology
of the inputs and columns. This value is used to calculate the inhibition
radius. This function supports an arbitrary number of dimensions. If the
number of column dimensions does not match t... | [
"The",
"average",
"number",
"of",
"columns",
"per",
"input",
"taking",
"into",
"account",
"the",
"topology",
"of",
"the",
"inputs",
"and",
"columns",
".",
"This",
"value",
"is",
"used",
"to",
"calculate",
"the",
"inhibition",
"radius",
".",
"This",
"function... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1062-L1080 | [
"def",
"_avgColumnsPerInput",
"(",
"self",
")",
":",
"#TODO: extend to support different number of dimensions for inputs and",
"# columns",
"numDim",
"=",
"max",
"(",
"self",
".",
"_columnDimensions",
".",
"size",
",",
"self",
".",
"_inputDimensions",
".",
"size",
")",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._avgConnectedSpanForColumn1D | The range of connected synapses for column. This is used to
calculate the inhibition radius. This variation of the function only
supports a 1 dimensional column topology.
Parameters:
----------------------------
:param columnIndex: The index identifying a column in the permanence,
... | src/nupic/algorithms/spatial_pooler.py | def _avgConnectedSpanForColumn1D(self, columnIndex):
"""
The range of connected synapses for column. This is used to
calculate the inhibition radius. This variation of the function only
supports a 1 dimensional column topology.
Parameters:
----------------------------
:param columnIndex: ... | def _avgConnectedSpanForColumn1D(self, columnIndex):
"""
The range of connected synapses for column. This is used to
calculate the inhibition radius. This variation of the function only
supports a 1 dimensional column topology.
Parameters:
----------------------------
:param columnIndex: ... | [
"The",
"range",
"of",
"connected",
"synapses",
"for",
"column",
".",
"This",
"is",
"used",
"to",
"calculate",
"the",
"inhibition",
"radius",
".",
"This",
"variation",
"of",
"the",
"function",
"only",
"supports",
"a",
"1",
"dimensional",
"column",
"topology",
... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1083-L1099 | [
"def",
"_avgConnectedSpanForColumn1D",
"(",
"self",
",",
"columnIndex",
")",
":",
"assert",
"(",
"self",
".",
"_inputDimensions",
".",
"size",
"==",
"1",
")",
"connected",
"=",
"self",
".",
"_connectedSynapses",
"[",
"columnIndex",
"]",
".",
"nonzero",
"(",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._avgConnectedSpanForColumn2D | The range of connectedSynapses per column, averaged for each dimension.
This value is used to calculate the inhibition radius. This variation of
the function only supports a 2 dimensional column topology.
Parameters:
----------------------------
:param columnIndex: The index identifying a column... | src/nupic/algorithms/spatial_pooler.py | def _avgConnectedSpanForColumn2D(self, columnIndex):
"""
The range of connectedSynapses per column, averaged for each dimension.
This value is used to calculate the inhibition radius. This variation of
the function only supports a 2 dimensional column topology.
Parameters:
--------------------... | def _avgConnectedSpanForColumn2D(self, columnIndex):
"""
The range of connectedSynapses per column, averaged for each dimension.
This value is used to calculate the inhibition radius. This variation of
the function only supports a 2 dimensional column topology.
Parameters:
--------------------... | [
"The",
"range",
"of",
"connectedSynapses",
"per",
"column",
"averaged",
"for",
"each",
"dimension",
".",
"This",
"value",
"is",
"used",
"to",
"calculate",
"the",
"inhibition",
"radius",
".",
"This",
"variation",
"of",
"the",
"function",
"only",
"supports",
"a"... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1102-L1120 | [
"def",
"_avgConnectedSpanForColumn2D",
"(",
"self",
",",
"columnIndex",
")",
":",
"assert",
"(",
"self",
".",
"_inputDimensions",
".",
"size",
"==",
"2",
")",
"connected",
"=",
"self",
".",
"_connectedSynapses",
"[",
"columnIndex",
"]",
"(",
"rows",
",",
"co... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._bumpUpWeakColumns | This method increases the permanence values of synapses of columns whose
activity level has been too low. Such columns are identified by having an
overlap duty cycle that drops too much below those of their peers. The
permanence values for such columns are increased. | src/nupic/algorithms/spatial_pooler.py | def _bumpUpWeakColumns(self):
"""
This method increases the permanence values of synapses of columns whose
activity level has been too low. Such columns are identified by having an
overlap duty cycle that drops too much below those of their peers. The
permanence values for such columns are increased... | def _bumpUpWeakColumns(self):
"""
This method increases the permanence values of synapses of columns whose
activity level has been too low. Such columns are identified by having an
overlap duty cycle that drops too much below those of their peers. The
permanence values for such columns are increased... | [
"This",
"method",
"increases",
"the",
"permanence",
"values",
"of",
"synapses",
"of",
"columns",
"whose",
"activity",
"level",
"has",
"been",
"too",
"low",
".",
"Such",
"columns",
"are",
"identified",
"by",
"having",
"an",
"overlap",
"duty",
"cycle",
"that",
... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1177-L1190 | [
"def",
"_bumpUpWeakColumns",
"(",
"self",
")",
":",
"weakColumns",
"=",
"numpy",
".",
"where",
"(",
"self",
".",
"_overlapDutyCycles",
"<",
"self",
".",
"_minOverlapDutyCycles",
")",
"[",
"0",
"]",
"for",
"columnIndex",
"in",
"weakColumns",
":",
"perm",
"=",... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._raisePermanenceToThreshold | This method ensures that each column has enough connections to input bits
to allow it to become active. Since a column must have at least
'self._stimulusThreshold' overlaps in order to be considered during the
inhibition phase, columns without such minimal number of connections, even
if all the input bi... | src/nupic/algorithms/spatial_pooler.py | def _raisePermanenceToThreshold(self, perm, mask):
"""
This method ensures that each column has enough connections to input bits
to allow it to become active. Since a column must have at least
'self._stimulusThreshold' overlaps in order to be considered during the
inhibition phase, columns without s... | def _raisePermanenceToThreshold(self, perm, mask):
"""
This method ensures that each column has enough connections to input bits
to allow it to become active. Since a column must have at least
'self._stimulusThreshold' overlaps in order to be considered during the
inhibition phase, columns without s... | [
"This",
"method",
"ensures",
"that",
"each",
"column",
"has",
"enough",
"connections",
"to",
"input",
"bits",
"to",
"allow",
"it",
"to",
"become",
"active",
".",
"Since",
"a",
"column",
"must",
"have",
"at",
"least",
"self",
".",
"_stimulusThreshold",
"overl... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1193-L1224 | [
"def",
"_raisePermanenceToThreshold",
"(",
"self",
",",
"perm",
",",
"mask",
")",
":",
"if",
"len",
"(",
"mask",
")",
"<",
"self",
".",
"_stimulusThreshold",
":",
"raise",
"Exception",
"(",
"\"This is likely due to a \"",
"+",
"\"value of stimulusThreshold that is t... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._updatePermanencesForColumn | This method updates the permanence matrix with a column's new permanence
values. The column is identified by its index, which reflects the row in
the matrix, and the permanence is given in 'dense' form, i.e. a full
array containing all the zeros as well as the non-zero values. It is in
charge of impleme... | src/nupic/algorithms/spatial_pooler.py | def _updatePermanencesForColumn(self, perm, columnIndex, raisePerm=True):
"""
This method updates the permanence matrix with a column's new permanence
values. The column is identified by its index, which reflects the row in
the matrix, and the permanence is given in 'dense' form, i.e. a full
array c... | def _updatePermanencesForColumn(self, perm, columnIndex, raisePerm=True):
"""
This method updates the permanence matrix with a column's new permanence
values. The column is identified by its index, which reflects the row in
the matrix, and the permanence is given in 'dense' form, i.e. a full
array c... | [
"This",
"method",
"updates",
"the",
"permanence",
"matrix",
"with",
"a",
"column",
"s",
"new",
"permanence",
"values",
".",
"The",
"column",
"is",
"identified",
"by",
"its",
"index",
"which",
"reflects",
"the",
"row",
"in",
"the",
"matrix",
"and",
"the",
"... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1227-L1263 | [
"def",
"_updatePermanencesForColumn",
"(",
"self",
",",
"perm",
",",
"columnIndex",
",",
"raisePerm",
"=",
"True",
")",
":",
"maskPotential",
"=",
"numpy",
".",
"where",
"(",
"self",
".",
"_potentialPools",
"[",
"columnIndex",
"]",
">",
"0",
")",
"[",
"0",... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._initPermConnected | Returns a randomly generated permanence value for a synapses that is
initialized in a connected state. The basic idea here is to initialize
permanence values very close to synPermConnected so that a small number of
learning steps could make it disconnected or connected.
Note: experimentation was done a... | src/nupic/algorithms/spatial_pooler.py | def _initPermConnected(self):
"""
Returns a randomly generated permanence value for a synapses that is
initialized in a connected state. The basic idea here is to initialize
permanence values very close to synPermConnected so that a small number of
learning steps could make it disconnected or connec... | def _initPermConnected(self):
"""
Returns a randomly generated permanence value for a synapses that is
initialized in a connected state. The basic idea here is to initialize
permanence values very close to synPermConnected so that a small number of
learning steps could make it disconnected or connec... | [
"Returns",
"a",
"randomly",
"generated",
"permanence",
"value",
"for",
"a",
"synapses",
"that",
"is",
"initialized",
"in",
"a",
"connected",
"state",
".",
"The",
"basic",
"idea",
"here",
"is",
"to",
"initialize",
"permanence",
"values",
"very",
"close",
"to",
... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1266-L1283 | [
"def",
"_initPermConnected",
"(",
"self",
")",
":",
"p",
"=",
"self",
".",
"_synPermConnected",
"+",
"(",
"self",
".",
"_synPermMax",
"-",
"self",
".",
"_synPermConnected",
")",
"*",
"self",
".",
"_random",
".",
"getReal64",
"(",
")",
"# Ensure we don't have... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._initPermNonConnected | Returns a randomly generated permanence value for a synapses that is to be
initialized in a non-connected state. | src/nupic/algorithms/spatial_pooler.py | def _initPermNonConnected(self):
"""
Returns a randomly generated permanence value for a synapses that is to be
initialized in a non-connected state.
"""
p = self._synPermConnected * self._random.getReal64()
# Ensure we don't have too much unnecessary precision. A full 64 bits of
# precisio... | def _initPermNonConnected(self):
"""
Returns a randomly generated permanence value for a synapses that is to be
initialized in a non-connected state.
"""
p = self._synPermConnected * self._random.getReal64()
# Ensure we don't have too much unnecessary precision. A full 64 bits of
# precisio... | [
"Returns",
"a",
"randomly",
"generated",
"permanence",
"value",
"for",
"a",
"synapses",
"that",
"is",
"to",
"be",
"initialized",
"in",
"a",
"non",
"-",
"connected",
"state",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1286-L1297 | [
"def",
"_initPermNonConnected",
"(",
"self",
")",
":",
"p",
"=",
"self",
".",
"_synPermConnected",
"*",
"self",
".",
"_random",
".",
"getReal64",
"(",
")",
"# Ensure we don't have too much unnecessary precision. A full 64 bits of",
"# precision causes numerical stability issu... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._initPermanence | Initializes the permanences of a column. The method
returns a 1-D array the size of the input, where each entry in the
array represents the initial permanence value between the input bit
at the particular index in the array, and the column represented by
the 'index' parameter.
Parameters:
-----... | src/nupic/algorithms/spatial_pooler.py | def _initPermanence(self, potential, connectedPct):
"""
Initializes the permanences of a column. The method
returns a 1-D array the size of the input, where each entry in the
array represents the initial permanence value between the input bit
at the particular index in the array, and the column repr... | def _initPermanence(self, potential, connectedPct):
"""
Initializes the permanences of a column. The method
returns a 1-D array the size of the input, where each entry in the
array represents the initial permanence value between the input bit
at the particular index in the array, and the column repr... | [
"Initializes",
"the",
"permanences",
"of",
"a",
"column",
".",
"The",
"method",
"returns",
"a",
"1",
"-",
"D",
"array",
"the",
"size",
"of",
"the",
"input",
"where",
"each",
"entry",
"in",
"the",
"array",
"represents",
"the",
"initial",
"permanence",
"valu... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1300-L1336 | [
"def",
"_initPermanence",
"(",
"self",
",",
"potential",
",",
"connectedPct",
")",
":",
"# Determine which inputs bits will start out as connected",
"# to the inputs. Initially a subset of the input bits in a",
"# column's potential pool will be connected. This number is",
"# given by the ... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._mapColumn | Maps a column to its respective input index, keeping to the topology of
the region. It takes the index of the column as an argument and determines
what is the index of the flattened input vector that is to be the center of
the column's potential pool. It distributes the columns over the inputs
uniformly... | src/nupic/algorithms/spatial_pooler.py | def _mapColumn(self, index):
"""
Maps a column to its respective input index, keeping to the topology of
the region. It takes the index of the column as an argument and determines
what is the index of the flattened input vector that is to be the center of
the column's potential pool. It distributes ... | def _mapColumn(self, index):
"""
Maps a column to its respective input index, keeping to the topology of
the region. It takes the index of the column as an argument and determines
what is the index of the flattened input vector that is to be the center of
the column's potential pool. It distributes ... | [
"Maps",
"a",
"column",
"to",
"its",
"respective",
"input",
"index",
"keeping",
"to",
"the",
"topology",
"of",
"the",
"region",
".",
"It",
"takes",
"the",
"index",
"of",
"the",
"column",
"as",
"an",
"argument",
"and",
"determines",
"what",
"is",
"the",
"i... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1339-L1368 | [
"def",
"_mapColumn",
"(",
"self",
",",
"index",
")",
":",
"columnCoords",
"=",
"numpy",
".",
"unravel_index",
"(",
"index",
",",
"self",
".",
"_columnDimensions",
")",
"columnCoords",
"=",
"numpy",
".",
"array",
"(",
"columnCoords",
",",
"dtype",
"=",
"rea... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._mapPotential | Maps a column to its input bits. This method encapsulates the topology of
the region. It takes the index of the column as an argument and determines
what are the indices of the input vector that are located within the
column's potential pool. The return value is a list containing the indices
of the inpu... | src/nupic/algorithms/spatial_pooler.py | def _mapPotential(self, index):
"""
Maps a column to its input bits. This method encapsulates the topology of
the region. It takes the index of the column as an argument and determines
what are the indices of the input vector that are located within the
column's potential pool. The return value is a... | def _mapPotential(self, index):
"""
Maps a column to its input bits. This method encapsulates the topology of
the region. It takes the index of the column as an argument and determines
what are the indices of the input vector that are located within the
column's potential pool. The return value is a... | [
"Maps",
"a",
"column",
"to",
"its",
"input",
"bits",
".",
"This",
"method",
"encapsulates",
"the",
"topology",
"of",
"the",
"region",
".",
"It",
"takes",
"the",
"index",
"of",
"the",
"column",
"as",
"an",
"argument",
"and",
"determines",
"what",
"are",
"... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1371-L1413 | [
"def",
"_mapPotential",
"(",
"self",
",",
"index",
")",
":",
"centerInput",
"=",
"self",
".",
"_mapColumn",
"(",
"index",
")",
"columnInputs",
"=",
"self",
".",
"_getInputNeighborhood",
"(",
"centerInput",
")",
".",
"astype",
"(",
"uintType",
")",
"# Select ... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._updateBoostFactorsGlobal | Update boost factors when global inhibition is used | src/nupic/algorithms/spatial_pooler.py | def _updateBoostFactorsGlobal(self):
"""
Update boost factors when global inhibition is used
"""
# When global inhibition is enabled, the target activation level is
# the sparsity of the spatial pooler
if (self._localAreaDensity > 0):
targetDensity = self._localAreaDensity
else:
... | def _updateBoostFactorsGlobal(self):
"""
Update boost factors when global inhibition is used
"""
# When global inhibition is enabled, the target activation level is
# the sparsity of the spatial pooler
if (self._localAreaDensity > 0):
targetDensity = self._localAreaDensity
else:
... | [
"Update",
"boost",
"factors",
"when",
"global",
"inhibition",
"is",
"used"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1476-L1492 | [
"def",
"_updateBoostFactorsGlobal",
"(",
"self",
")",
":",
"# When global inhibition is enabled, the target activation level is",
"# the sparsity of the spatial pooler",
"if",
"(",
"self",
".",
"_localAreaDensity",
">",
"0",
")",
":",
"targetDensity",
"=",
"self",
".",
"_lo... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._updateBoostFactorsLocal | Update boost factors when local inhibition is used | src/nupic/algorithms/spatial_pooler.py | def _updateBoostFactorsLocal(self):
"""
Update boost factors when local inhibition is used
"""
# Determine the target activation level for each column
# The targetDensity is the average activeDutyCycles of the neighboring
# columns of each column.
targetDensity = numpy.zeros(self._numColumns... | def _updateBoostFactorsLocal(self):
"""
Update boost factors when local inhibition is used
"""
# Determine the target activation level for each column
# The targetDensity is the average activeDutyCycles of the neighboring
# columns of each column.
targetDensity = numpy.zeros(self._numColumns... | [
"Update",
"boost",
"factors",
"when",
"local",
"inhibition",
"is",
"used"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1496-L1509 | [
"def",
"_updateBoostFactorsLocal",
"(",
"self",
")",
":",
"# Determine the target activation level for each column",
"# The targetDensity is the average activeDutyCycles of the neighboring",
"# columns of each column.",
"targetDensity",
"=",
"numpy",
".",
"zeros",
"(",
"self",
".",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._calculateOverlap | This function determines each column's overlap with the current input
vector. The overlap of a column is the number of synapses for that column
that are connected (permanence value is greater than '_synPermConnected')
to input bits which are turned on. The implementation takes advantage of
the SparseBin... | src/nupic/algorithms/spatial_pooler.py | def _calculateOverlap(self, inputVector):
"""
This function determines each column's overlap with the current input
vector. The overlap of a column is the number of synapses for that column
that are connected (permanence value is greater than '_synPermConnected')
to input bits which are turned on. T... | def _calculateOverlap(self, inputVector):
"""
This function determines each column's overlap with the current input
vector. The overlap of a column is the number of synapses for that column
that are connected (permanence value is greater than '_synPermConnected')
to input bits which are turned on. T... | [
"This",
"function",
"determines",
"each",
"column",
"s",
"overlap",
"with",
"the",
"current",
"input",
"vector",
".",
"The",
"overlap",
"of",
"a",
"column",
"is",
"the",
"number",
"of",
"synapses",
"for",
"that",
"column",
"that",
"are",
"connected",
"(",
... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1529-L1545 | [
"def",
"_calculateOverlap",
"(",
"self",
",",
"inputVector",
")",
":",
"overlaps",
"=",
"numpy",
".",
"zeros",
"(",
"self",
".",
"_numColumns",
",",
"dtype",
"=",
"realDType",
")",
"self",
".",
"_connectedSynapses",
".",
"rightVecSumAtNZ_fast",
"(",
"inputVect... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._inhibitColumns | Performs inhibition. This method calculates the necessary values needed to
actually perform inhibition and then delegates the task of picking the
active columns to helper functions.
Parameters:
----------------------------
:param overlaps: an array containing the overlap score for each column.
... | src/nupic/algorithms/spatial_pooler.py | def _inhibitColumns(self, overlaps):
"""
Performs inhibition. This method calculates the necessary values needed to
actually perform inhibition and then delegates the task of picking the
active columns to helper functions.
Parameters:
----------------------------
:param overlaps: an array c... | def _inhibitColumns(self, overlaps):
"""
Performs inhibition. This method calculates the necessary values needed to
actually perform inhibition and then delegates the task of picking the
active columns to helper functions.
Parameters:
----------------------------
:param overlaps: an array c... | [
"Performs",
"inhibition",
".",
"This",
"method",
"calculates",
"the",
"necessary",
"values",
"needed",
"to",
"actually",
"perform",
"inhibition",
"and",
"then",
"delegates",
"the",
"task",
"of",
"picking",
"the",
"active",
"columns",
"to",
"helper",
"functions",
... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1552-L1581 | [
"def",
"_inhibitColumns",
"(",
"self",
",",
"overlaps",
")",
":",
"# determine how many columns should be selected in the inhibition phase.",
"# This can be specified by either setting the 'numActiveColumnsPerInhArea'",
"# parameter or the 'localAreaDensity' parameter when initializing the class... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._inhibitColumnsGlobal | Perform global inhibition. Performing global inhibition entails picking the
top 'numActive' columns with the highest overlap score in the entire
region. At most half of the columns in a local neighborhood are allowed to
be active. Columns with an overlap score below the 'stimulusThreshold' are
always in... | src/nupic/algorithms/spatial_pooler.py | def _inhibitColumnsGlobal(self, overlaps, density):
"""
Perform global inhibition. Performing global inhibition entails picking the
top 'numActive' columns with the highest overlap score in the entire
region. At most half of the columns in a local neighborhood are allowed to
be active. Columns with ... | def _inhibitColumnsGlobal(self, overlaps, density):
"""
Perform global inhibition. Performing global inhibition entails picking the
top 'numActive' columns with the highest overlap score in the entire
region. At most half of the columns in a local neighborhood are allowed to
be active. Columns with ... | [
"Perform",
"global",
"inhibition",
".",
"Performing",
"global",
"inhibition",
"entails",
"picking",
"the",
"top",
"numActive",
"columns",
"with",
"the",
"highest",
"overlap",
"score",
"in",
"the",
"entire",
"region",
".",
"At",
"most",
"half",
"of",
"the",
"co... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1584-L1615 | [
"def",
"_inhibitColumnsGlobal",
"(",
"self",
",",
"overlaps",
",",
"density",
")",
":",
"#calculate num active per inhibition area",
"numActive",
"=",
"int",
"(",
"density",
"*",
"self",
".",
"_numColumns",
")",
"# Calculate winners using stable sort algorithm (mergesort)",... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._inhibitColumnsLocal | Performs local inhibition. Local inhibition is performed on a column by
column basis. Each column observes the overlaps of its neighbors and is
selected if its overlap score is within the top 'numActive' in its local
neighborhood. At most half of the columns in a local neighborhood are
allowed to be act... | src/nupic/algorithms/spatial_pooler.py | def _inhibitColumnsLocal(self, overlaps, density):
"""
Performs local inhibition. Local inhibition is performed on a column by
column basis. Each column observes the overlaps of its neighbors and is
selected if its overlap score is within the top 'numActive' in its local
neighborhood. At most half o... | def _inhibitColumnsLocal(self, overlaps, density):
"""
Performs local inhibition. Local inhibition is performed on a column by
column basis. Each column observes the overlaps of its neighbors and is
selected if its overlap score is within the top 'numActive' in its local
neighborhood. At most half o... | [
"Performs",
"local",
"inhibition",
".",
"Local",
"inhibition",
"is",
"performed",
"on",
"a",
"column",
"by",
"column",
"basis",
".",
"Each",
"column",
"observes",
"the",
"overlaps",
"of",
"its",
"neighbors",
"and",
"is",
"selected",
"if",
"its",
"overlap",
"... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1618-L1657 | [
"def",
"_inhibitColumnsLocal",
"(",
"self",
",",
"overlaps",
",",
"density",
")",
":",
"activeArray",
"=",
"numpy",
".",
"zeros",
"(",
"self",
".",
"_numColumns",
",",
"dtype",
"=",
"\"bool\"",
")",
"for",
"column",
",",
"overlap",
"in",
"enumerate",
"(",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._getColumnNeighborhood | Gets a neighborhood of columns.
Simply calls topology.neighborhood or topology.wrappingNeighborhood
A subclass can insert different topology behavior by overriding this method.
:param centerColumn (int)
The center of the neighborhood.
@returns (1D numpy array of integers)
The columns in the ... | src/nupic/algorithms/spatial_pooler.py | def _getColumnNeighborhood(self, centerColumn):
"""
Gets a neighborhood of columns.
Simply calls topology.neighborhood or topology.wrappingNeighborhood
A subclass can insert different topology behavior by overriding this method.
:param centerColumn (int)
The center of the neighborhood.
@... | def _getColumnNeighborhood(self, centerColumn):
"""
Gets a neighborhood of columns.
Simply calls topology.neighborhood or topology.wrappingNeighborhood
A subclass can insert different topology behavior by overriding this method.
:param centerColumn (int)
The center of the neighborhood.
@... | [
"Gets",
"a",
"neighborhood",
"of",
"columns",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1668-L1690 | [
"def",
"_getColumnNeighborhood",
"(",
"self",
",",
"centerColumn",
")",
":",
"if",
"self",
".",
"_wrapAround",
":",
"return",
"topology",
".",
"wrappingNeighborhood",
"(",
"centerColumn",
",",
"self",
".",
"_inhibitionRadius",
",",
"self",
".",
"_columnDimensions"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._getInputNeighborhood | Gets a neighborhood of inputs.
Simply calls topology.wrappingNeighborhood or topology.neighborhood.
A subclass can insert different topology behavior by overriding this method.
:param centerInput (int)
The center of the neighborhood.
@returns (1D numpy array of integers)
The inputs in the ne... | src/nupic/algorithms/spatial_pooler.py | def _getInputNeighborhood(self, centerInput):
"""
Gets a neighborhood of inputs.
Simply calls topology.wrappingNeighborhood or topology.neighborhood.
A subclass can insert different topology behavior by overriding this method.
:param centerInput (int)
The center of the neighborhood.
@ret... | def _getInputNeighborhood(self, centerInput):
"""
Gets a neighborhood of inputs.
Simply calls topology.wrappingNeighborhood or topology.neighborhood.
A subclass can insert different topology behavior by overriding this method.
:param centerInput (int)
The center of the neighborhood.
@ret... | [
"Gets",
"a",
"neighborhood",
"of",
"inputs",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1694-L1715 | [
"def",
"_getInputNeighborhood",
"(",
"self",
",",
"centerInput",
")",
":",
"if",
"self",
".",
"_wrapAround",
":",
"return",
"topology",
".",
"wrappingNeighborhood",
"(",
"centerInput",
",",
"self",
".",
"_potentialRadius",
",",
"self",
".",
"_inputDimensions",
"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SpatialPooler._seed | Initialize the random seed | src/nupic/algorithms/spatial_pooler.py | def _seed(self, seed=-1):
"""
Initialize the random seed
"""
if seed != -1:
self._random = NupicRandom(seed)
else:
self._random = NupicRandom() | def _seed(self, seed=-1):
"""
Initialize the random seed
"""
if seed != -1:
self._random = NupicRandom(seed)
else:
self._random = NupicRandom() | [
"Initialize",
"the",
"random",
"seed"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1718-L1725 | [
"def",
"_seed",
"(",
"self",
",",
"seed",
"=",
"-",
"1",
")",
":",
"if",
"seed",
"!=",
"-",
"1",
":",
"self",
".",
"_random",
"=",
"NupicRandom",
"(",
"seed",
")",
"else",
":",
"self",
".",
"_random",
"=",
"NupicRandom",
"(",
")"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | DictValueGetter.handleGetValue | This method overrides ValueGetterBase's "pure virtual" method. It
returns the referenced value. The derived class is NOT responsible for
fully resolving the reference'd value in the event the value resolves to
another ValueGetterBase-based instance -- this is handled automatically
within ValueGetterBa... | src/nupic/frameworks/opf/exp_description_helpers.py | def handleGetValue(self, topContainer):
""" This method overrides ValueGetterBase's "pure virtual" method. It
returns the referenced value. The derived class is NOT responsible for
fully resolving the reference'd value in the event the value resolves to
another ValueGetterBase-based instance -- this i... | def handleGetValue(self, topContainer):
""" This method overrides ValueGetterBase's "pure virtual" method. It
returns the referenced value. The derived class is NOT responsible for
fully resolving the reference'd value in the event the value resolves to
another ValueGetterBase-based instance -- this i... | [
"This",
"method",
"overrides",
"ValueGetterBase",
"s",
"pure",
"virtual",
"method",
".",
"It",
"returns",
"the",
"referenced",
"value",
".",
"The",
"derived",
"class",
"is",
"NOT",
"responsible",
"for",
"fully",
"resolving",
"the",
"reference",
"d",
"value",
"... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/exp_description_helpers.py#L264-L284 | [
"def",
"handleGetValue",
"(",
"self",
",",
"topContainer",
")",
":",
"value",
"=",
"self",
".",
"__referenceDict",
"if",
"self",
".",
"__referenceDict",
"is",
"not",
"None",
"else",
"topContainer",
"for",
"key",
"in",
"self",
".",
"__dictKeyChain",
":",
"val... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | Array | Factory function that creates typed Array or ArrayRef objects
dtype - the data type of the array (as string).
Supported types are: Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Real32, Real64
size - the size of the array. Must be positive integer. | src/nupic/engine/__init__.py | def Array(dtype, size=None, ref=False):
"""Factory function that creates typed Array or ArrayRef objects
dtype - the data type of the array (as string).
Supported types are: Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Real32, Real64
size - the size of the array. Must be positive integer.
"""
def... | def Array(dtype, size=None, ref=False):
"""Factory function that creates typed Array or ArrayRef objects
dtype - the data type of the array (as string).
Supported types are: Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Real32, Real64
size - the size of the array. Must be positive integer.
"""
def... | [
"Factory",
"function",
"that",
"creates",
"typed",
"Array",
"or",
"ArrayRef",
"objects"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/engine/__init__.py#L178-L215 | [
"def",
"Array",
"(",
"dtype",
",",
"size",
"=",
"None",
",",
"ref",
"=",
"False",
")",
":",
"def",
"getArrayType",
"(",
"self",
")",
":",
"\"\"\"A little function to replace the getType() method of arrays\n\n It returns a string representation of the array element type ins... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | Region.getInputNames | Returns list of input names in spec. | src/nupic/engine/__init__.py | def getInputNames(self):
"""
Returns list of input names in spec.
"""
inputs = self.getSpec().inputs
return [inputs.getByIndex(i)[0] for i in xrange(inputs.getCount())] | def getInputNames(self):
"""
Returns list of input names in spec.
"""
inputs = self.getSpec().inputs
return [inputs.getByIndex(i)[0] for i in xrange(inputs.getCount())] | [
"Returns",
"list",
"of",
"input",
"names",
"in",
"spec",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/engine/__init__.py#L449-L454 | [
"def",
"getInputNames",
"(",
"self",
")",
":",
"inputs",
"=",
"self",
".",
"getSpec",
"(",
")",
".",
"inputs",
"return",
"[",
"inputs",
".",
"getByIndex",
"(",
"i",
")",
"[",
"0",
"]",
"for",
"i",
"in",
"xrange",
"(",
"inputs",
".",
"getCount",
"("... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | Region.getOutputNames | Returns list of output names in spec. | src/nupic/engine/__init__.py | def getOutputNames(self):
"""
Returns list of output names in spec.
"""
outputs = self.getSpec().outputs
return [outputs.getByIndex(i)[0] for i in xrange(outputs.getCount())] | def getOutputNames(self):
"""
Returns list of output names in spec.
"""
outputs = self.getSpec().outputs
return [outputs.getByIndex(i)[0] for i in xrange(outputs.getCount())] | [
"Returns",
"list",
"of",
"output",
"names",
"in",
"spec",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/engine/__init__.py#L456-L461 | [
"def",
"getOutputNames",
"(",
"self",
")",
":",
"outputs",
"=",
"self",
".",
"getSpec",
"(",
")",
".",
"outputs",
"return",
"[",
"outputs",
".",
"getByIndex",
"(",
"i",
")",
"[",
"0",
"]",
"for",
"i",
"in",
"xrange",
"(",
"outputs",
".",
"getCount",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | Region._getParameterMethods | Returns functions to set/get the parameter. These are
the strongly typed functions get/setParameterUInt32, etc.
The return value is a pair:
setfunc, getfunc
If the parameter is not available on this region, setfunc/getfunc
are None. | src/nupic/engine/__init__.py | def _getParameterMethods(self, paramName):
"""Returns functions to set/get the parameter. These are
the strongly typed functions get/setParameterUInt32, etc.
The return value is a pair:
setfunc, getfunc
If the parameter is not available on this region, setfunc/getfunc
are None. """
if pa... | def _getParameterMethods(self, paramName):
"""Returns functions to set/get the parameter. These are
the strongly typed functions get/setParameterUInt32, etc.
The return value is a pair:
setfunc, getfunc
If the parameter is not available on this region, setfunc/getfunc
are None. """
if pa... | [
"Returns",
"functions",
"to",
"set",
"/",
"get",
"the",
"parameter",
".",
"These",
"are",
"the",
"strongly",
"typed",
"functions",
"get",
"/",
"setParameterUInt32",
"etc",
".",
"The",
"return",
"value",
"is",
"a",
"pair",
":",
"setfunc",
"getfunc",
"If",
"... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/engine/__init__.py#L493-L529 | [
"def",
"_getParameterMethods",
"(",
"self",
",",
"paramName",
")",
":",
"if",
"paramName",
"in",
"self",
".",
"_paramTypeCache",
":",
"return",
"self",
".",
"_paramTypeCache",
"[",
"paramName",
"]",
"try",
":",
"# Catch the error here. We will re-throw in getParameter... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | Region.getParameter | Get parameter value | src/nupic/engine/__init__.py | def getParameter(self, paramName):
"""Get parameter value"""
(setter, getter) = self._getParameterMethods(paramName)
if getter is None:
import exceptions
raise exceptions.Exception(
"getParameter -- parameter name '%s' does not exist in region %s of type %s"
% (paramName, sel... | def getParameter(self, paramName):
"""Get parameter value"""
(setter, getter) = self._getParameterMethods(paramName)
if getter is None:
import exceptions
raise exceptions.Exception(
"getParameter -- parameter name '%s' does not exist in region %s of type %s"
% (paramName, sel... | [
"Get",
"parameter",
"value"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/engine/__init__.py#L531-L539 | [
"def",
"getParameter",
"(",
"self",
",",
"paramName",
")",
":",
"(",
"setter",
",",
"getter",
")",
"=",
"self",
".",
"_getParameterMethods",
"(",
"paramName",
")",
"if",
"getter",
"is",
"None",
":",
"import",
"exceptions",
"raise",
"exceptions",
".",
"Exce... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | Region.setParameter | Set parameter value | src/nupic/engine/__init__.py | def setParameter(self, paramName, value):
"""Set parameter value"""
(setter, getter) = self._getParameterMethods(paramName)
if setter is None:
import exceptions
raise exceptions.Exception(
"setParameter -- parameter name '%s' does not exist in region %s of type %s"
% (paramNa... | def setParameter(self, paramName, value):
"""Set parameter value"""
(setter, getter) = self._getParameterMethods(paramName)
if setter is None:
import exceptions
raise exceptions.Exception(
"setParameter -- parameter name '%s' does not exist in region %s of type %s"
% (paramNa... | [
"Set",
"parameter",
"value"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/engine/__init__.py#L541-L549 | [
"def",
"setParameter",
"(",
"self",
",",
"paramName",
",",
"value",
")",
":",
"(",
"setter",
",",
"getter",
")",
"=",
"self",
".",
"_getParameterMethods",
"(",
"paramName",
")",
"if",
"setter",
"is",
"None",
":",
"import",
"exceptions",
"raise",
"exception... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | Network._getRegions | Get the collection of regions in a network
This is a tricky one. The collection of regions returned from
from the internal network is a collection of internal regions.
The desired collection is a collelcion of net.Region objects
that also points to this network (net.network) and not to
the internal... | src/nupic/engine/__init__.py | def _getRegions(self):
"""Get the collection of regions in a network
This is a tricky one. The collection of regions returned from
from the internal network is a collection of internal regions.
The desired collection is a collelcion of net.Region objects
that also points to this network (net.networ... | def _getRegions(self):
"""Get the collection of regions in a network
This is a tricky one. The collection of regions returned from
from the internal network is a collection of internal regions.
The desired collection is a collelcion of net.Region objects
that also points to this network (net.networ... | [
"Get",
"the",
"collection",
"of",
"regions",
"in",
"a",
"network"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/engine/__init__.py#L615-L639 | [
"def",
"_getRegions",
"(",
"self",
")",
":",
"def",
"makeRegion",
"(",
"name",
",",
"r",
")",
":",
"\"\"\"Wrap a engine region with a nupic.engine_internal.Region\n\n Also passes the containing nupic.engine_internal.Network network in _network. This\n function is passed a value... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | Network.getRegionsByType | Gets all region instances of a given class
(for example, nupic.regions.sp_region.SPRegion). | src/nupic/engine/__init__.py | def getRegionsByType(self, regionClass):
"""
Gets all region instances of a given class
(for example, nupic.regions.sp_region.SPRegion).
"""
regions = []
for region in self.regions.values():
if type(region.getSelf()) is regionClass:
regions.append(region)
return regions | def getRegionsByType(self, regionClass):
"""
Gets all region instances of a given class
(for example, nupic.regions.sp_region.SPRegion).
"""
regions = []
for region in self.regions.values():
if type(region.getSelf()) is regionClass:
regions.append(region)
return regions | [
"Gets",
"all",
"region",
"instances",
"of",
"a",
"given",
"class",
"(",
"for",
"example",
"nupic",
".",
"regions",
".",
"sp_region",
".",
"SPRegion",
")",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/engine/__init__.py#L731-L742 | [
"def",
"getRegionsByType",
"(",
"self",
",",
"regionClass",
")",
":",
"regions",
"=",
"[",
"]",
"for",
"region",
"in",
"self",
".",
"regions",
".",
"values",
"(",
")",
":",
"if",
"type",
"(",
"region",
".",
"getSelf",
"(",
")",
")",
"is",
"regionClas... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SDRClassifierRegion.getSpec | Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getSpec`. | src/nupic/regions/sdr_classifier_region.py | def getSpec(cls):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getSpec`.
"""
ns = dict(
description=SDRClassifierRegion.__doc__,
singleNodeOnly=True,
inputs=dict(
actValueIn=dict(
description="Actual value of the field to predict. Only taken "
... | def getSpec(cls):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getSpec`.
"""
ns = dict(
description=SDRClassifierRegion.__doc__,
singleNodeOnly=True,
inputs=dict(
actValueIn=dict(
description="Actual value of the field to predict. Only taken "
... | [
"Overrides",
":",
"meth",
":",
"nupic",
".",
"bindings",
".",
"regions",
".",
"PyRegion",
".",
"PyRegion",
".",
"getSpec",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/sdr_classifier_region.py#L76-L238 | [
"def",
"getSpec",
"(",
"cls",
")",
":",
"ns",
"=",
"dict",
"(",
"description",
"=",
"SDRClassifierRegion",
".",
"__doc__",
",",
"singleNodeOnly",
"=",
"True",
",",
"inputs",
"=",
"dict",
"(",
"actValueIn",
"=",
"dict",
"(",
"description",
"=",
"\"Actual va... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SDRClassifierRegion.initialize | Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.initialize`.
Is called once by NuPIC before the first call to compute().
Initializes self._sdrClassifier if it is not already initialized. | src/nupic/regions/sdr_classifier_region.py | def initialize(self):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.initialize`.
Is called once by NuPIC before the first call to compute().
Initializes self._sdrClassifier if it is not already initialized.
"""
if self._sdrClassifier is None:
self._sdrClassifier = SDRClass... | def initialize(self):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.initialize`.
Is called once by NuPIC before the first call to compute().
Initializes self._sdrClassifier if it is not already initialized.
"""
if self._sdrClassifier is None:
self._sdrClassifier = SDRClass... | [
"Overrides",
":",
"meth",
":",
"nupic",
".",
"bindings",
".",
"regions",
".",
"PyRegion",
".",
"PyRegion",
".",
"initialize",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/sdr_classifier_region.py#L276-L289 | [
"def",
"initialize",
"(",
"self",
")",
":",
"if",
"self",
".",
"_sdrClassifier",
"is",
"None",
":",
"self",
".",
"_sdrClassifier",
"=",
"SDRClassifierFactory",
".",
"create",
"(",
"steps",
"=",
"self",
".",
"stepsList",
",",
"alpha",
"=",
"self",
".",
"a... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SDRClassifierRegion.setParameter | Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.setParameter`. | src/nupic/regions/sdr_classifier_region.py | def setParameter(self, name, index, value):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.setParameter`.
"""
if name == "learningMode":
self.learningMode = bool(int(value))
elif name == "inferenceMode":
self.inferenceMode = bool(int(value))
else:
return PyRegion... | def setParameter(self, name, index, value):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.setParameter`.
"""
if name == "learningMode":
self.learningMode = bool(int(value))
elif name == "inferenceMode":
self.inferenceMode = bool(int(value))
else:
return PyRegion... | [
"Overrides",
":",
"meth",
":",
"nupic",
".",
"bindings",
".",
"regions",
".",
"PyRegion",
".",
"PyRegion",
".",
"setParameter",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/sdr_classifier_region.py#L308-L317 | [
"def",
"setParameter",
"(",
"self",
",",
"name",
",",
"index",
",",
"value",
")",
":",
"if",
"name",
"==",
"\"learningMode\"",
":",
"self",
".",
"learningMode",
"=",
"bool",
"(",
"int",
"(",
"value",
")",
")",
"elif",
"name",
"==",
"\"inferenceMode\"",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SDRClassifierRegion.writeToProto | Write state to proto object.
:param proto: SDRClassifierRegionProto capnproto object | src/nupic/regions/sdr_classifier_region.py | def writeToProto(self, proto):
"""
Write state to proto object.
:param proto: SDRClassifierRegionProto capnproto object
"""
proto.implementation = self.implementation
proto.steps = self.steps
proto.alpha = self.alpha
proto.verbosity = self.verbosity
proto.maxCategoryCount = self.max... | def writeToProto(self, proto):
"""
Write state to proto object.
:param proto: SDRClassifierRegionProto capnproto object
"""
proto.implementation = self.implementation
proto.steps = self.steps
proto.alpha = self.alpha
proto.verbosity = self.verbosity
proto.maxCategoryCount = self.max... | [
"Write",
"state",
"to",
"proto",
"object",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/sdr_classifier_region.py#L328-L343 | [
"def",
"writeToProto",
"(",
"self",
",",
"proto",
")",
":",
"proto",
".",
"implementation",
"=",
"self",
".",
"implementation",
"proto",
".",
"steps",
"=",
"self",
".",
"steps",
"proto",
".",
"alpha",
"=",
"self",
".",
"alpha",
"proto",
".",
"verbosity",... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SDRClassifierRegion.readFromProto | Read state from proto object.
:param proto: SDRClassifierRegionProto capnproto object | src/nupic/regions/sdr_classifier_region.py | def readFromProto(cls, proto):
"""
Read state from proto object.
:param proto: SDRClassifierRegionProto capnproto object
"""
instance = cls()
instance.implementation = proto.implementation
instance.steps = proto.steps
instance.stepsList = [int(i) for i in proto.steps.split(",")]
in... | def readFromProto(cls, proto):
"""
Read state from proto object.
:param proto: SDRClassifierRegionProto capnproto object
"""
instance = cls()
instance.implementation = proto.implementation
instance.steps = proto.steps
instance.stepsList = [int(i) for i in proto.steps.split(",")]
in... | [
"Read",
"state",
"from",
"proto",
"object",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/sdr_classifier_region.py#L347-L368 | [
"def",
"readFromProto",
"(",
"cls",
",",
"proto",
")",
":",
"instance",
"=",
"cls",
"(",
")",
"instance",
".",
"implementation",
"=",
"proto",
".",
"implementation",
"instance",
".",
"steps",
"=",
"proto",
".",
"steps",
"instance",
".",
"stepsList",
"=",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SDRClassifierRegion.compute | Process one input sample.
This method is called by the runtime engine.
:param inputs: (dict) mapping region input names to numpy.array values
:param outputs: (dict) mapping region output names to numpy.arrays that
should be populated with output values by this method | src/nupic/regions/sdr_classifier_region.py | def compute(self, inputs, outputs):
"""
Process one input sample.
This method is called by the runtime engine.
:param inputs: (dict) mapping region input names to numpy.array values
:param outputs: (dict) mapping region output names to numpy.arrays that
should be populated with output v... | def compute(self, inputs, outputs):
"""
Process one input sample.
This method is called by the runtime engine.
:param inputs: (dict) mapping region input names to numpy.array values
:param outputs: (dict) mapping region output names to numpy.arrays that
should be populated with output v... | [
"Process",
"one",
"input",
"sample",
".",
"This",
"method",
"is",
"called",
"by",
"the",
"runtime",
"engine",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/sdr_classifier_region.py#L372-L456 | [
"def",
"compute",
"(",
"self",
",",
"inputs",
",",
"outputs",
")",
":",
"# This flag helps to prevent double-computation, in case the deprecated",
"# customCompute() method is being called in addition to compute() called",
"# when network.run() is called",
"self",
".",
"_computeFlag",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SDRClassifierRegion.customCompute | Just return the inference value from one input sample. The actual
learning happens in compute() -- if, and only if learning is enabled --
which is called when you run the network.
.. warning:: This method is deprecated and exists only to maintain backward
compatibility. This method is deprecated, a... | src/nupic/regions/sdr_classifier_region.py | def customCompute(self, recordNum, patternNZ, classification):
"""
Just return the inference value from one input sample. The actual
learning happens in compute() -- if, and only if learning is enabled --
which is called when you run the network.
.. warning:: This method is deprecated and exists on... | def customCompute(self, recordNum, patternNZ, classification):
"""
Just return the inference value from one input sample. The actual
learning happens in compute() -- if, and only if learning is enabled --
which is called when you run the network.
.. warning:: This method is deprecated and exists on... | [
"Just",
"return",
"the",
"inference",
"value",
"from",
"one",
"input",
"sample",
".",
"The",
"actual",
"learning",
"happens",
"in",
"compute",
"()",
"--",
"if",
"and",
"only",
"if",
"learning",
"is",
"enabled",
"--",
"which",
"is",
"called",
"when",
"you",... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/sdr_classifier_region.py#L459-L510 | [
"def",
"customCompute",
"(",
"self",
",",
"recordNum",
",",
"patternNZ",
",",
"classification",
")",
":",
"# If the compute flag has not been initialized (for example if we",
"# restored a model from an old checkpoint) initialize it to False.",
"if",
"not",
"hasattr",
"(",
"self"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SDRClassifierRegion.getOutputElementCount | Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getOutputElementCount`. | src/nupic/regions/sdr_classifier_region.py | def getOutputElementCount(self, outputName):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getOutputElementCount`.
"""
if outputName == "categoriesOut":
return len(self.stepsList)
elif outputName == "probabilities":
return len(self.stepsList) * self.maxCategoryCount
e... | def getOutputElementCount(self, outputName):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getOutputElementCount`.
"""
if outputName == "categoriesOut":
return len(self.stepsList)
elif outputName == "probabilities":
return len(self.stepsList) * self.maxCategoryCount
e... | [
"Overrides",
":",
"meth",
":",
"nupic",
".",
"bindings",
".",
"regions",
".",
"PyRegion",
".",
"PyRegion",
".",
"getOutputElementCount",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/sdr_classifier_region.py#L514-L525 | [
"def",
"getOutputElementCount",
"(",
"self",
",",
"outputName",
")",
":",
"if",
"outputName",
"==",
"\"categoriesOut\"",
":",
"return",
"len",
"(",
"self",
".",
"stepsList",
")",
"elif",
"outputName",
"==",
"\"probabilities\"",
":",
"return",
"len",
"(",
"self... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | OPFModelRunner.run | Runs the OPF Model
Parameters:
-------------------------------------------------------------------------
retval: (completionReason, completionMsg)
where completionReason is one of the ClientJobsDAO.CMPL_REASON_XXX
equates. | src/nupic/swarming/ModelRunner.py | def run(self):
""" Runs the OPF Model
Parameters:
-------------------------------------------------------------------------
retval: (completionReason, completionMsg)
where completionReason is one of the ClientJobsDAO.CMPL_REASON_XXX
equates.
"""
# ----------------... | def run(self):
""" Runs the OPF Model
Parameters:
-------------------------------------------------------------------------
retval: (completionReason, completionMsg)
where completionReason is one of the ClientJobsDAO.CMPL_REASON_XXX
equates.
"""
# ----------------... | [
"Runs",
"the",
"OPF",
"Model"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/ModelRunner.py#L209-L289 | [
"def",
"run",
"(",
"self",
")",
":",
"# -----------------------------------------------------------------------",
"# Load the experiment's description.py module",
"descriptionPyModule",
"=",
"helpers",
".",
"loadExperimentDescriptionScriptFromDir",
"(",
"self",
".",
"_experimentDir",... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | OPFModelRunner.__runTaskMainLoop | Main loop of the OPF Model Runner.
Parameters:
-----------------------------------------------------------------------
recordIterator: Iterator for counting number of records (see _runTask)
learningOffAt: If not None, learning is turned off when we reach this
iteration n... | src/nupic/swarming/ModelRunner.py | def __runTaskMainLoop(self, numIters, learningOffAt=None):
""" Main loop of the OPF Model Runner.
Parameters:
-----------------------------------------------------------------------
recordIterator: Iterator for counting number of records (see _runTask)
learningOffAt: If not None, learning i... | def __runTaskMainLoop(self, numIters, learningOffAt=None):
""" Main loop of the OPF Model Runner.
Parameters:
-----------------------------------------------------------------------
recordIterator: Iterator for counting number of records (see _runTask)
learningOffAt: If not None, learning i... | [
"Main",
"loop",
"of",
"the",
"OPF",
"Model",
"Runner",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/ModelRunner.py#L292-L391 | [
"def",
"__runTaskMainLoop",
"(",
"self",
",",
"numIters",
",",
"learningOffAt",
"=",
"None",
")",
":",
"## Reset sequence states in the model, so it starts looking for a new",
"## sequence",
"self",
".",
"_model",
".",
"resetSequenceStates",
"(",
")",
"self",
".",
"_cur... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.