repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
Calysto/calysto | calysto/ai/conx.py | Network.getLayerIndex | def getLayerIndex(self, layer):
"""
Given a reference to a layer, returns the index of that layer in
self.layers.
"""
for i in range(len(self.layers)):
if layer == self.layers[i]: # shallow cmp
return i
return -1 # not in list | python | def getLayerIndex(self, layer):
"""
Given a reference to a layer, returns the index of that layer in
self.layers.
"""
for i in range(len(self.layers)):
if layer == self.layers[i]: # shallow cmp
return i
return -1 # not in list | [
"def",
"getLayerIndex",
"(",
"self",
",",
"layer",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"layers",
")",
")",
":",
"if",
"layer",
"==",
"self",
".",
"layers",
"[",
"i",
"]",
":",
"# shallow cmp",
"return",
"i",
"return",... | Given a reference to a layer, returns the index of that layer in
self.layers. | [
"Given",
"a",
"reference",
"to",
"a",
"layer",
"returns",
"the",
"index",
"of",
"that",
"layer",
"in",
"self",
".",
"layers",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L911-L919 |
Calysto/calysto | calysto/ai/conx.py | Network.add | def add(self, layer, verbosity = 0, position = None):
"""
Adds a layer. Layer verbosity is optional (default 0).
"""
layer._verbosity = verbosity
layer._maxRandom = self._maxRandom
layer.minTarget = 0.0
layer.maxTarget = 1.0
layer.minActivation = 0.0
... | python | def add(self, layer, verbosity = 0, position = None):
"""
Adds a layer. Layer verbosity is optional (default 0).
"""
layer._verbosity = verbosity
layer._maxRandom = self._maxRandom
layer.minTarget = 0.0
layer.maxTarget = 1.0
layer.minActivation = 0.0
... | [
"def",
"add",
"(",
"self",
",",
"layer",
",",
"verbosity",
"=",
"0",
",",
"position",
"=",
"None",
")",
":",
"layer",
".",
"_verbosity",
"=",
"verbosity",
"layer",
".",
"_maxRandom",
"=",
"self",
".",
"_maxRandom",
"layer",
".",
"minTarget",
"=",
"0.0"... | Adds a layer. Layer verbosity is optional (default 0). | [
"Adds",
"a",
"layer",
".",
"Layer",
"verbosity",
"is",
"optional",
"(",
"default",
"0",
")",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L927-L941 |
Calysto/calysto | calysto/ai/conx.py | Network.isConnected | def isConnected(self, fromName, toName):
""" Are these two layers connected this way? """
for c in self.connections:
if (c.fromLayer.name == fromName and
c.toLayer.name == toName):
return 1
return 0 | python | def isConnected(self, fromName, toName):
""" Are these two layers connected this way? """
for c in self.connections:
if (c.fromLayer.name == fromName and
c.toLayer.name == toName):
return 1
return 0 | [
"def",
"isConnected",
"(",
"self",
",",
"fromName",
",",
"toName",
")",
":",
"for",
"c",
"in",
"self",
".",
"connections",
":",
"if",
"(",
"c",
".",
"fromLayer",
".",
"name",
"==",
"fromName",
"and",
"c",
".",
"toLayer",
".",
"name",
"==",
"toName",
... | Are these two layers connected this way? | [
"Are",
"these",
"two",
"layers",
"connected",
"this",
"way?"
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L942-L948 |
Calysto/calysto | calysto/ai/conx.py | Network.connect | def connect(self, *names):
"""
Connects a list of names, one to the next.
"""
fromName, toName, rest = names[0], names[1], names[2:]
self.connectAt(fromName, toName)
if len(rest) != 0:
self.connect(toName, *rest) | python | def connect(self, *names):
"""
Connects a list of names, one to the next.
"""
fromName, toName, rest = names[0], names[1], names[2:]
self.connectAt(fromName, toName)
if len(rest) != 0:
self.connect(toName, *rest) | [
"def",
"connect",
"(",
"self",
",",
"*",
"names",
")",
":",
"fromName",
",",
"toName",
",",
"rest",
"=",
"names",
"[",
"0",
"]",
",",
"names",
"[",
"1",
"]",
",",
"names",
"[",
"2",
":",
"]",
"self",
".",
"connectAt",
"(",
"fromName",
",",
"toN... | Connects a list of names, one to the next. | [
"Connects",
"a",
"list",
"of",
"names",
"one",
"to",
"the",
"next",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L949-L956 |
Calysto/calysto | calysto/ai/conx.py | Network.connectAt | def connectAt(self, fromName, toName, position = None):
"""
Connects two layers by instantiating an instance of Connection
class. Allows a position number, indicating the ordering of
the connection.
"""
fromLayer = self.getLayer(fromName)
toLayer = self.getLayer... | python | def connectAt(self, fromName, toName, position = None):
"""
Connects two layers by instantiating an instance of Connection
class. Allows a position number, indicating the ordering of
the connection.
"""
fromLayer = self.getLayer(fromName)
toLayer = self.getLayer... | [
"def",
"connectAt",
"(",
"self",
",",
"fromName",
",",
"toName",
",",
"position",
"=",
"None",
")",
":",
"fromLayer",
"=",
"self",
".",
"getLayer",
"(",
"fromName",
")",
"toLayer",
"=",
"self",
".",
"getLayer",
"(",
"toName",
")",
"if",
"self",
".",
... | Connects two layers by instantiating an instance of Connection
class. Allows a position number, indicating the ordering of
the connection. | [
"Connects",
"two",
"layers",
"by",
"instantiating",
"an",
"instance",
"of",
"Connection",
"class",
".",
"Allows",
"a",
"position",
"number",
"indicating",
"the",
"ordering",
"of",
"the",
"connection",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L957-L987 |
Calysto/calysto | calysto/ai/conx.py | Network.addLayers | def addLayers(self, *arg, **kw):
"""
Creates an N layer network with 'input', 'hidden1', 'hidden2',...
and 'output' layers. Keyword type indicates "parallel" or
"serial". If only one hidden layer, it is called "hidden".
"""
netType = "serial"
if "type" in kw:
... | python | def addLayers(self, *arg, **kw):
"""
Creates an N layer network with 'input', 'hidden1', 'hidden2',...
and 'output' layers. Keyword type indicates "parallel" or
"serial". If only one hidden layer, it is called "hidden".
"""
netType = "serial"
if "type" in kw:
... | [
"def",
"addLayers",
"(",
"self",
",",
"*",
"arg",
",",
"*",
"*",
"kw",
")",
":",
"netType",
"=",
"\"serial\"",
"if",
"\"type\"",
"in",
"kw",
":",
"netType",
"=",
"kw",
"[",
"\"type\"",
"]",
"self",
".",
"addLayer",
"(",
"'input'",
",",
"arg",
"[",
... | Creates an N layer network with 'input', 'hidden1', 'hidden2',...
and 'output' layers. Keyword type indicates "parallel" or
"serial". If only one hidden layer, it is called "hidden". | [
"Creates",
"an",
"N",
"layer",
"network",
"with",
"input",
"hidden1",
"hidden2",
"...",
"and",
"output",
"layers",
".",
"Keyword",
"type",
"indicates",
"parallel",
"or",
"serial",
".",
"If",
"only",
"one",
"hidden",
"layer",
"it",
"is",
"called",
"hidden",
... | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L998-L1034 |
Calysto/calysto | calysto/ai/conx.py | Network.deleteLayerNode | def deleteLayerNode(self, layername, nodeNum):
"""
Removes a particular unit/node from a layer.
"""
# first, construct an array of all of the weights
# that won't be deleted:
gene = []
for layer in self.layers:
if layer.type != 'Input':
... | python | def deleteLayerNode(self, layername, nodeNum):
"""
Removes a particular unit/node from a layer.
"""
# first, construct an array of all of the weights
# that won't be deleted:
gene = []
for layer in self.layers:
if layer.type != 'Input':
... | [
"def",
"deleteLayerNode",
"(",
"self",
",",
"layername",
",",
"nodeNum",
")",
":",
"# first, construct an array of all of the weights",
"# that won't be deleted:",
"gene",
"=",
"[",
"]",
"for",
"layer",
"in",
"self",
".",
"layers",
":",
"if",
"layer",
".",
"type",... | Removes a particular unit/node from a layer. | [
"Removes",
"a",
"particular",
"unit",
"/",
"node",
"from",
"a",
"layer",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1038-L1063 |
Calysto/calysto | calysto/ai/conx.py | Network.addLayerNode | def addLayerNode(self, layerName, bias = None, weights = {}):
"""
Adds a new node to a layer, and puts in new weights. Adds node on the end.
Weights will be random, unless specified.
bias = the new node's bias weight
weights = dict of {connectedLayerName: [weights], ...}
... | python | def addLayerNode(self, layerName, bias = None, weights = {}):
"""
Adds a new node to a layer, and puts in new weights. Adds node on the end.
Weights will be random, unless specified.
bias = the new node's bias weight
weights = dict of {connectedLayerName: [weights], ...}
... | [
"def",
"addLayerNode",
"(",
"self",
",",
"layerName",
",",
"bias",
"=",
"None",
",",
"weights",
"=",
"{",
"}",
")",
":",
"self",
".",
"changeLayerSize",
"(",
"layerName",
",",
"self",
"[",
"layerName",
"]",
".",
"size",
"+",
"1",
")",
"if",
"bias",
... | Adds a new node to a layer, and puts in new weights. Adds node on the end.
Weights will be random, unless specified.
bias = the new node's bias weight
weights = dict of {connectedLayerName: [weights], ...}
Example:
>>> net = Network() # doctest: +ELLIPSIS
Conx using ... | [
"Adds",
"a",
"new",
"node",
"to",
"a",
"layer",
"and",
"puts",
"in",
"new",
"weights",
".",
"Adds",
"node",
"on",
"the",
"end",
".",
"Weights",
"will",
"be",
"random",
"unless",
"specified",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1064-L1088 |
Calysto/calysto | calysto/ai/conx.py | Network.changeLayerSize | def changeLayerSize(self, layername, newsize):
"""
Changes layer size. Newsize must be greater than zero.
"""
# for all connection from to this layer, change matrix:
if self.sharedWeights:
raise AttributeError("shared weights broken")
for connection in self.co... | python | def changeLayerSize(self, layername, newsize):
"""
Changes layer size. Newsize must be greater than zero.
"""
# for all connection from to this layer, change matrix:
if self.sharedWeights:
raise AttributeError("shared weights broken")
for connection in self.co... | [
"def",
"changeLayerSize",
"(",
"self",
",",
"layername",
",",
"newsize",
")",
":",
"# for all connection from to this layer, change matrix:",
"if",
"self",
".",
"sharedWeights",
":",
"raise",
"AttributeError",
"(",
"\"shared weights broken\"",
")",
"for",
"connection",
... | Changes layer size. Newsize must be greater than zero. | [
"Changes",
"layer",
"size",
".",
"Newsize",
"must",
"be",
"greater",
"than",
"zero",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1089-L1102 |
Calysto/calysto | calysto/ai/conx.py | Network.initialize | def initialize(self):
"""
Initializes network by calling Connection.initialize() and
Layer.initialize(). self.count is set to zero.
"""
print("Initializing '%s' weights..." % self.name, end=" ", file=sys.stderr)
if self.sharedWeights:
raise AttributeError("sha... | python | def initialize(self):
"""
Initializes network by calling Connection.initialize() and
Layer.initialize(). self.count is set to zero.
"""
print("Initializing '%s' weights..." % self.name, end=" ", file=sys.stderr)
if self.sharedWeights:
raise AttributeError("sha... | [
"def",
"initialize",
"(",
"self",
")",
":",
"print",
"(",
"\"Initializing '%s' weights...\"",
"%",
"self",
".",
"name",
",",
"end",
"=",
"\" \"",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"if",
"self",
".",
"sharedWeights",
":",
"raise",
"AttributeError... | Initializes network by calling Connection.initialize() and
Layer.initialize(). self.count is set to zero. | [
"Initializes",
"network",
"by",
"calling",
"Connection",
".",
"initialize",
"()",
"and",
"Layer",
".",
"initialize",
"()",
".",
"self",
".",
"count",
"is",
"set",
"to",
"zero",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1110-L1122 |
Calysto/calysto | calysto/ai/conx.py | Network.putActivations | def putActivations(self, dict):
"""
Puts a dict of name: activations into their respective layers.
"""
for name in dict:
self.layersByName[name].copyActivations( dict[name] ) | python | def putActivations(self, dict):
"""
Puts a dict of name: activations into their respective layers.
"""
for name in dict:
self.layersByName[name].copyActivations( dict[name] ) | [
"def",
"putActivations",
"(",
"self",
",",
"dict",
")",
":",
"for",
"name",
"in",
"dict",
":",
"self",
".",
"layersByName",
"[",
"name",
"]",
".",
"copyActivations",
"(",
"dict",
"[",
"name",
"]",
")"
] | Puts a dict of name: activations into their respective layers. | [
"Puts",
"a",
"dict",
"of",
"name",
":",
"activations",
"into",
"their",
"respective",
"layers",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1131-L1136 |
Calysto/calysto | calysto/ai/conx.py | Network.getActivationsDict | def getActivationsDict(self, nameList):
"""
Returns a dictionary of layer names that map to a list of activations.
"""
retval = {}
for name in nameList:
retval[name] = self.layersByName[name].getActivationsList()
return retval | python | def getActivationsDict(self, nameList):
"""
Returns a dictionary of layer names that map to a list of activations.
"""
retval = {}
for name in nameList:
retval[name] = self.layersByName[name].getActivationsList()
return retval | [
"def",
"getActivationsDict",
"(",
"self",
",",
"nameList",
")",
":",
"retval",
"=",
"{",
"}",
"for",
"name",
"in",
"nameList",
":",
"retval",
"[",
"name",
"]",
"=",
"self",
".",
"layersByName",
"[",
"name",
"]",
".",
"getActivationsList",
"(",
")",
"re... | Returns a dictionary of layer names that map to a list of activations. | [
"Returns",
"a",
"dictionary",
"of",
"layer",
"names",
"that",
"map",
"to",
"a",
"list",
"of",
"activations",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1137-L1144 |
Calysto/calysto | calysto/ai/conx.py | Network.setSeed | def setSeed(self, value):
"""
Sets the seed to value.
"""
self.seed = value
random.seed(self.seed)
if self.verbosity >= 0:
print("Conx using seed:", self.seed) | python | def setSeed(self, value):
"""
Sets the seed to value.
"""
self.seed = value
random.seed(self.seed)
if self.verbosity >= 0:
print("Conx using seed:", self.seed) | [
"def",
"setSeed",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"seed",
"=",
"value",
"random",
".",
"seed",
"(",
"self",
".",
"seed",
")",
"if",
"self",
".",
"verbosity",
">=",
"0",
":",
"print",
"(",
"\"Conx using seed:\"",
",",
"self",
".",
... | Sets the seed to value. | [
"Sets",
"the",
"seed",
"to",
"value",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1218-L1225 |
Calysto/calysto | calysto/ai/conx.py | Network.getConnection | def getConnection(self, lfrom, lto):
"""
Returns the connection instance connecting the specified (string)
layer names.
"""
for connection in self.connections:
if connection.fromLayer.name == lfrom and \
connection.toLayer.name == lto:
r... | python | def getConnection(self, lfrom, lto):
"""
Returns the connection instance connecting the specified (string)
layer names.
"""
for connection in self.connections:
if connection.fromLayer.name == lfrom and \
connection.toLayer.name == lto:
r... | [
"def",
"getConnection",
"(",
"self",
",",
"lfrom",
",",
"lto",
")",
":",
"for",
"connection",
"in",
"self",
".",
"connections",
":",
"if",
"connection",
".",
"fromLayer",
".",
"name",
"==",
"lfrom",
"and",
"connection",
".",
"toLayer",
".",
"name",
"==",... | Returns the connection instance connecting the specified (string)
layer names. | [
"Returns",
"the",
"connection",
"instance",
"connecting",
"the",
"specified",
"(",
"string",
")",
"layer",
"names",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1226-L1235 |
Calysto/calysto | calysto/ai/conx.py | Network.setVerbosity | def setVerbosity(self, value):
"""
Sets network self._verbosity and each layer._verbosity to value.
"""
self._verbosity = value
for layer in self.layers:
layer._verbosity = value | python | def setVerbosity(self, value):
"""
Sets network self._verbosity and each layer._verbosity to value.
"""
self._verbosity = value
for layer in self.layers:
layer._verbosity = value | [
"def",
"setVerbosity",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_verbosity",
"=",
"value",
"for",
"layer",
"in",
"self",
".",
"layers",
":",
"layer",
".",
"_verbosity",
"=",
"value"
] | Sets network self._verbosity and each layer._verbosity to value. | [
"Sets",
"network",
"self",
".",
"_verbosity",
"and",
"each",
"layer",
".",
"_verbosity",
"to",
"value",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1236-L1242 |
Calysto/calysto | calysto/ai/conx.py | Network.setMaxRandom | def setMaxRandom(self, value):
"""
Sets the maxRandom Layer attribute for each layer to value.Specifies
the global range for randomly initialized values, [-max, max].
"""
self._maxRandom = value
for layer in self.layers:
layer._maxRandom = value | python | def setMaxRandom(self, value):
"""
Sets the maxRandom Layer attribute for each layer to value.Specifies
the global range for randomly initialized values, [-max, max].
"""
self._maxRandom = value
for layer in self.layers:
layer._maxRandom = value | [
"def",
"setMaxRandom",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_maxRandom",
"=",
"value",
"for",
"layer",
"in",
"self",
".",
"layers",
":",
"layer",
".",
"_maxRandom",
"=",
"value"
] | Sets the maxRandom Layer attribute for each layer to value.Specifies
the global range for randomly initialized values, [-max, max]. | [
"Sets",
"the",
"maxRandom",
"Layer",
"attribute",
"for",
"each",
"layer",
"to",
"value",
".",
"Specifies",
"the",
"global",
"range",
"for",
"randomly",
"initialized",
"values",
"[",
"-",
"max",
"max",
"]",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1276-L1283 |
Calysto/calysto | calysto/ai/conx.py | Network.getWeights | def getWeights(self, fromName, toName):
"""
Gets the weights of the connection between two layers (argument strings).
"""
for connection in self.connections:
if connection.fromLayer.name == fromName and \
connection.toLayer.name == toName:
retur... | python | def getWeights(self, fromName, toName):
"""
Gets the weights of the connection between two layers (argument strings).
"""
for connection in self.connections:
if connection.fromLayer.name == fromName and \
connection.toLayer.name == toName:
retur... | [
"def",
"getWeights",
"(",
"self",
",",
"fromName",
",",
"toName",
")",
":",
"for",
"connection",
"in",
"self",
".",
"connections",
":",
"if",
"connection",
".",
"fromLayer",
".",
"name",
"==",
"fromName",
"and",
"connection",
".",
"toLayer",
".",
"name",
... | Gets the weights of the connection between two layers (argument strings). | [
"Gets",
"the",
"weights",
"of",
"the",
"connection",
"between",
"two",
"layers",
"(",
"argument",
"strings",
")",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1284-L1292 |
Calysto/calysto | calysto/ai/conx.py | Network.setWeight | def setWeight(self, fromName, fromPos, toName, toPos, value):
"""
Sets the weight of the connection between two layers (argument strings).
"""
for connection in self.connections:
if connection.fromLayer.name == fromName and \
connection.toLayer.name == toName:
... | python | def setWeight(self, fromName, fromPos, toName, toPos, value):
"""
Sets the weight of the connection between two layers (argument strings).
"""
for connection in self.connections:
if connection.fromLayer.name == fromName and \
connection.toLayer.name == toName:
... | [
"def",
"setWeight",
"(",
"self",
",",
"fromName",
",",
"fromPos",
",",
"toName",
",",
"toPos",
",",
"value",
")",
":",
"for",
"connection",
"in",
"self",
".",
"connections",
":",
"if",
"connection",
".",
"fromLayer",
".",
"name",
"==",
"fromName",
"and",... | Sets the weight of the connection between two layers (argument strings). | [
"Sets",
"the",
"weight",
"of",
"the",
"connection",
"between",
"two",
"layers",
"(",
"argument",
"strings",
")",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1293-L1302 |
Calysto/calysto | calysto/ai/conx.py | Network.setOrderedInputs | def setOrderedInputs(self, value):
"""
Sets self.orderedInputs to value. Specifies if inputs
should be ordered and if so orders the inputs.
"""
self.orderedInputs = value
if self.orderedInputs:
self.loadOrder = [0] * len(self.inputs)
for i in range... | python | def setOrderedInputs(self, value):
"""
Sets self.orderedInputs to value. Specifies if inputs
should be ordered and if so orders the inputs.
"""
self.orderedInputs = value
if self.orderedInputs:
self.loadOrder = [0] * len(self.inputs)
for i in range... | [
"def",
"setOrderedInputs",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"orderedInputs",
"=",
"value",
"if",
"self",
".",
"orderedInputs",
":",
"self",
".",
"loadOrder",
"=",
"[",
"0",
"]",
"*",
"len",
"(",
"self",
".",
"inputs",
")",
"for",
"i"... | Sets self.orderedInputs to value. Specifies if inputs
should be ordered and if so orders the inputs. | [
"Sets",
"self",
".",
"orderedInputs",
"to",
"value",
".",
"Specifies",
"if",
"inputs",
"should",
"be",
"ordered",
"and",
"if",
"so",
"orders",
"the",
"inputs",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1303-L1312 |
Calysto/calysto | calysto/ai/conx.py | Network.verifyArguments | def verifyArguments(self, arg):
"""
Verifies that arguments to setInputs and setTargets are appropriately formatted.
"""
for l in arg:
if not type(l) == list and \
not type(l) == type(Numeric.array([0.0])) and \
not type(l) == tuple and \
... | python | def verifyArguments(self, arg):
"""
Verifies that arguments to setInputs and setTargets are appropriately formatted.
"""
for l in arg:
if not type(l) == list and \
not type(l) == type(Numeric.array([0.0])) and \
not type(l) == tuple and \
... | [
"def",
"verifyArguments",
"(",
"self",
",",
"arg",
")",
":",
"for",
"l",
"in",
"arg",
":",
"if",
"not",
"type",
"(",
"l",
")",
"==",
"list",
"and",
"not",
"type",
"(",
"l",
")",
"==",
"type",
"(",
"Numeric",
".",
"array",
"(",
"[",
"0.0",
"]",
... | Verifies that arguments to setInputs and setTargets are appropriately formatted. | [
"Verifies",
"that",
"arguments",
"to",
"setInputs",
"and",
"setTargets",
"are",
"appropriately",
"formatted",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1313-L1331 |
Calysto/calysto | calysto/ai/conx.py | Network.setInputs | def setInputs(self, inputs):
"""
Sets self.input to inputs. Load order is by default random. Use setOrderedInputs() to order inputs.
"""
if not self.verifyArguments(inputs) and not self.patterned:
raise NetworkError('setInputs() requires [[...],[...],...] or [{"layerName": [.... | python | def setInputs(self, inputs):
"""
Sets self.input to inputs. Load order is by default random. Use setOrderedInputs() to order inputs.
"""
if not self.verifyArguments(inputs) and not self.patterned:
raise NetworkError('setInputs() requires [[...],[...],...] or [{"layerName": [.... | [
"def",
"setInputs",
"(",
"self",
",",
"inputs",
")",
":",
"if",
"not",
"self",
".",
"verifyArguments",
"(",
"inputs",
")",
"and",
"not",
"self",
".",
"patterned",
":",
"raise",
"NetworkError",
"(",
"'setInputs() requires [[...],[...],...] or [{\"layerName\": [...]},... | Sets self.input to inputs. Load order is by default random. Use setOrderedInputs() to order inputs. | [
"Sets",
"self",
".",
"input",
"to",
"inputs",
".",
"Load",
"order",
"is",
"by",
"default",
"random",
".",
"Use",
"setOrderedInputs",
"()",
"to",
"order",
"inputs",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1332-L1341 |
Calysto/calysto | calysto/ai/conx.py | Network.setTargets | def setTargets(self, targets):
"""
Sets the targets.
"""
if not self.verifyArguments(targets) and not self.patterned:
raise NetworkError('setTargets() requires [[...],[...],...] or [{"layerName": [...]}, ...].', targets)
self.targets = targets | python | def setTargets(self, targets):
"""
Sets the targets.
"""
if not self.verifyArguments(targets) and not self.patterned:
raise NetworkError('setTargets() requires [[...],[...],...] or [{"layerName": [...]}, ...].', targets)
self.targets = targets | [
"def",
"setTargets",
"(",
"self",
",",
"targets",
")",
":",
"if",
"not",
"self",
".",
"verifyArguments",
"(",
"targets",
")",
"and",
"not",
"self",
".",
"patterned",
":",
"raise",
"NetworkError",
"(",
"'setTargets() requires [[...],[...],...] or [{\"layerName\": [..... | Sets the targets. | [
"Sets",
"the",
"targets",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1348-L1354 |
Calysto/calysto | calysto/ai/conx.py | Network.setInputsAndTargets | def setInputsAndTargets(self, data1, data2=None):
"""
Network.setInputsAndTargets()
Sets the corpus of data for training. Can be in one of two formats:
Format 1: setInputsAndTargets([[input0, target0], [input1, target1]...])
Network.setInputsAndTargets([[[i00, i01, ...], [t00, t... | python | def setInputsAndTargets(self, data1, data2=None):
"""
Network.setInputsAndTargets()
Sets the corpus of data for training. Can be in one of two formats:
Format 1: setInputsAndTargets([[input0, target0], [input1, target1]...])
Network.setInputsAndTargets([[[i00, i01, ...], [t00, t... | [
"def",
"setInputsAndTargets",
"(",
"self",
",",
"data1",
",",
"data2",
"=",
"None",
")",
":",
"if",
"data2",
"==",
"None",
":",
"# format #1",
"inputs",
"=",
"[",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"data1",
"]",
"targets",
"=",
"[",
"x",
"[",
... | Network.setInputsAndTargets()
Sets the corpus of data for training. Can be in one of two formats:
Format 1: setInputsAndTargets([[input0, target0], [input1, target1]...])
Network.setInputsAndTargets([[[i00, i01, ...], [t00, t01, ...]],
[[i10, i11, ...], [t10... | [
"Network",
".",
"setInputsAndTargets",
"()",
"Sets",
"the",
"corpus",
"of",
"data",
"for",
"training",
".",
"Can",
"be",
"in",
"one",
"of",
"two",
"formats",
":"
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1355-L1376 |
Calysto/calysto | calysto/ai/conx.py | Network.randomizeOrder | def randomizeOrder(self):
"""
Randomizes self.loadOrder, the order in which inputs set with
self.setInputs() are presented.
"""
flag = [0] * len(self.inputs)
self.loadOrder = [0] * len(self.inputs)
for i in range(len(self.inputs)):
pos = int(random.ran... | python | def randomizeOrder(self):
"""
Randomizes self.loadOrder, the order in which inputs set with
self.setInputs() are presented.
"""
flag = [0] * len(self.inputs)
self.loadOrder = [0] * len(self.inputs)
for i in range(len(self.inputs)):
pos = int(random.ran... | [
"def",
"randomizeOrder",
"(",
"self",
")",
":",
"flag",
"=",
"[",
"0",
"]",
"*",
"len",
"(",
"self",
".",
"inputs",
")",
"self",
".",
"loadOrder",
"=",
"[",
"0",
"]",
"*",
"len",
"(",
"self",
".",
"inputs",
")",
"for",
"i",
"in",
"range",
"(",
... | Randomizes self.loadOrder, the order in which inputs set with
self.setInputs() are presented. | [
"Randomizes",
"self",
".",
"loadOrder",
"the",
"order",
"in",
"which",
"inputs",
"set",
"with",
"self",
".",
"setInputs",
"()",
"are",
"presented",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1400-L1412 |
Calysto/calysto | calysto/ai/conx.py | Network.copyVector | def copyVector(self, vector1, vec2, start):
"""
Copies vec2 into vector1 being sure to replace patterns if
necessary. Use self.copyActivations() or self.copyTargets()
instead.
"""
vector2 = self.replacePatterns(vec2)
length = min(len(vector1), len(vector2))
... | python | def copyVector(self, vector1, vec2, start):
"""
Copies vec2 into vector1 being sure to replace patterns if
necessary. Use self.copyActivations() or self.copyTargets()
instead.
"""
vector2 = self.replacePatterns(vec2)
length = min(len(vector1), len(vector2))
... | [
"def",
"copyVector",
"(",
"self",
",",
"vector1",
",",
"vec2",
",",
"start",
")",
":",
"vector2",
"=",
"self",
".",
"replacePatterns",
"(",
"vec2",
")",
"length",
"=",
"min",
"(",
"len",
"(",
"vector1",
")",
",",
"len",
"(",
"vector2",
")",
")",
"i... | Copies vec2 into vector1 being sure to replace patterns if
necessary. Use self.copyActivations() or self.copyTargets()
instead. | [
"Copies",
"vec2",
"into",
"vector1",
"being",
"sure",
"to",
"replace",
"patterns",
"if",
"necessary",
".",
"Use",
"self",
".",
"copyActivations",
"()",
"or",
"self",
".",
"copyTargets",
"()",
"instead",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1414-L1427 |
Calysto/calysto | calysto/ai/conx.py | Network.copyActivations | def copyActivations(self, layer, vec, start = 0):
"""
Copies activations in vec to the specified layer, replacing
patterns if necessary.
"""
vector = self.replacePatterns(vec, layer.name)
if self.verbosity > 4:
print("Copying Activations: ", vector[start:start... | python | def copyActivations(self, layer, vec, start = 0):
"""
Copies activations in vec to the specified layer, replacing
patterns if necessary.
"""
vector = self.replacePatterns(vec, layer.name)
if self.verbosity > 4:
print("Copying Activations: ", vector[start:start... | [
"def",
"copyActivations",
"(",
"self",
",",
"layer",
",",
"vec",
",",
"start",
"=",
"0",
")",
":",
"vector",
"=",
"self",
".",
"replacePatterns",
"(",
"vec",
",",
"layer",
".",
"name",
")",
"if",
"self",
".",
"verbosity",
">",
"4",
":",
"print",
"(... | Copies activations in vec to the specified layer, replacing
patterns if necessary. | [
"Copies",
"activations",
"in",
"vec",
"to",
"the",
"specified",
"layer",
"replacing",
"patterns",
"if",
"necessary",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1428-L1436 |
Calysto/calysto | calysto/ai/conx.py | Network.getDataCrossValidation | def getDataCrossValidation(self, pos):
"""
Returns the inputs/targets for a pattern pos, or assumes that
the layers are called input and output and uses the lists
in self.inputs and self.targets.
"""
set = {}
if type(self.inputs[pos]) == dict:
set.upda... | python | def getDataCrossValidation(self, pos):
"""
Returns the inputs/targets for a pattern pos, or assumes that
the layers are called input and output and uses the lists
in self.inputs and self.targets.
"""
set = {}
if type(self.inputs[pos]) == dict:
set.upda... | [
"def",
"getDataCrossValidation",
"(",
"self",
",",
"pos",
")",
":",
"set",
"=",
"{",
"}",
"if",
"type",
"(",
"self",
".",
"inputs",
"[",
"pos",
"]",
")",
"==",
"dict",
":",
"set",
".",
"update",
"(",
"self",
".",
"inputs",
"[",
"pos",
"]",
")",
... | Returns the inputs/targets for a pattern pos, or assumes that
the layers are called input and output and uses the lists
in self.inputs and self.targets. | [
"Returns",
"the",
"inputs",
"/",
"targets",
"for",
"a",
"pattern",
"pos",
"or",
"assumes",
"that",
"the",
"layers",
"are",
"called",
"input",
"and",
"output",
"and",
"uses",
"the",
"lists",
"in",
"self",
".",
"inputs",
"and",
"self",
".",
"targets",
"."
... | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1446-L1462 |
Calysto/calysto | calysto/ai/conx.py | Network.getDataMap | def getDataMap(self, intype, pos, name, offset = 0):
"""
Hook defined to lookup a name, and get it from a vector.
Can be overloaded to get it from somewhere else.
"""
if intype == "input":
vector = self.inputs
elif intype == "target":
vector = self... | python | def getDataMap(self, intype, pos, name, offset = 0):
"""
Hook defined to lookup a name, and get it from a vector.
Can be overloaded to get it from somewhere else.
"""
if intype == "input":
vector = self.inputs
elif intype == "target":
vector = self... | [
"def",
"getDataMap",
"(",
"self",
",",
"intype",
",",
"pos",
",",
"name",
",",
"offset",
"=",
"0",
")",
":",
"if",
"intype",
"==",
"\"input\"",
":",
"vector",
"=",
"self",
".",
"inputs",
"elif",
"intype",
"==",
"\"target\"",
":",
"vector",
"=",
"self... | Hook defined to lookup a name, and get it from a vector.
Can be overloaded to get it from somewhere else. | [
"Hook",
"defined",
"to",
"lookup",
"a",
"name",
"and",
"get",
"it",
"from",
"a",
"vector",
".",
"Can",
"be",
"overloaded",
"to",
"get",
"it",
"from",
"somewhere",
"else",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1463-L1474 |
Calysto/calysto | calysto/ai/conx.py | Network.getData | def getData(self, pos):
"""
Returns dictionary with input and target given pos.
"""
retval = {}
if pos >= len(self.inputs):
raise IndexError('getData() pattern beyond range.', pos)
if self.verbosity >= 1: print("Getting input", pos, "...")
if len(self... | python | def getData(self, pos):
"""
Returns dictionary with input and target given pos.
"""
retval = {}
if pos >= len(self.inputs):
raise IndexError('getData() pattern beyond range.', pos)
if self.verbosity >= 1: print("Getting input", pos, "...")
if len(self... | [
"def",
"getData",
"(",
"self",
",",
"pos",
")",
":",
"retval",
"=",
"{",
"}",
"if",
"pos",
">=",
"len",
"(",
"self",
".",
"inputs",
")",
":",
"raise",
"IndexError",
"(",
"'getData() pattern beyond range.'",
",",
"pos",
")",
"if",
"self",
".",
"verbosit... | Returns dictionary with input and target given pos. | [
"Returns",
"dictionary",
"with",
"input",
"and",
"target",
"given",
"pos",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1475-L1504 |
Calysto/calysto | calysto/ai/conx.py | Network.verifyArchitecture | def verifyArchitecture(self):
"""
Check for orphaned layers or connections. Assure that network
architecture is feed-forward (no-cycles). Check connectivity. Check naming.
"""
if len(self.cacheLayers) != 0 or len(self.cacheConnections) != 0: return
# flags for layer type ... | python | def verifyArchitecture(self):
"""
Check for orphaned layers or connections. Assure that network
architecture is feed-forward (no-cycles). Check connectivity. Check naming.
"""
if len(self.cacheLayers) != 0 or len(self.cacheConnections) != 0: return
# flags for layer type ... | [
"def",
"verifyArchitecture",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"cacheLayers",
")",
"!=",
"0",
"or",
"len",
"(",
"self",
".",
"cacheConnections",
")",
"!=",
"0",
":",
"return",
"# flags for layer type tests",
"hiddenInput",
"=",
"1",
"hi... | Check for orphaned layers or connections. Assure that network
architecture is feed-forward (no-cycles). Check connectivity. Check naming. | [
"Check",
"for",
"orphaned",
"layers",
"or",
"connections",
".",
"Assure",
"that",
"network",
"architecture",
"is",
"feed",
"-",
"forward",
"(",
"no",
"-",
"cycles",
")",
".",
"Check",
"connectivity",
".",
"Check",
"naming",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1507-L1593 |
Calysto/calysto | calysto/ai/conx.py | Network.verifyInputs | def verifyInputs(self):
"""
Used in propagate() to verify that the network input
activations have been set.
"""
for layer in self.layers:
if (layer.verify and
layer.type == 'Input' and
layer.kind != 'Context' and
layer.a... | python | def verifyInputs(self):
"""
Used in propagate() to verify that the network input
activations have been set.
"""
for layer in self.layers:
if (layer.verify and
layer.type == 'Input' and
layer.kind != 'Context' and
layer.a... | [
"def",
"verifyInputs",
"(",
"self",
")",
":",
"for",
"layer",
"in",
"self",
".",
"layers",
":",
"if",
"(",
"layer",
".",
"verify",
"and",
"layer",
".",
"type",
"==",
"'Input'",
"and",
"layer",
".",
"kind",
"!=",
"'Context'",
"and",
"layer",
".",
"act... | Used in propagate() to verify that the network input
activations have been set. | [
"Used",
"in",
"propagate",
"()",
"to",
"verify",
"that",
"the",
"network",
"input",
"activations",
"have",
"been",
"set",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1594-L1607 |
Calysto/calysto | calysto/ai/conx.py | Network.verifyTargets | def verifyTargets(self):
"""
Used in backprop() to verify that the network targets have
been set.
"""
for layer in self.layers:
if layer.verify and layer.type == 'Output' and layer.active and not layer.targetSet:
raise LayerError('Targets are not set a... | python | def verifyTargets(self):
"""
Used in backprop() to verify that the network targets have
been set.
"""
for layer in self.layers:
if layer.verify and layer.type == 'Output' and layer.active and not layer.targetSet:
raise LayerError('Targets are not set a... | [
"def",
"verifyTargets",
"(",
"self",
")",
":",
"for",
"layer",
"in",
"self",
".",
"layers",
":",
"if",
"layer",
".",
"verify",
"and",
"layer",
".",
"type",
"==",
"'Output'",
"and",
"layer",
".",
"active",
"and",
"not",
"layer",
".",
"targetSet",
":",
... | Used in backprop() to verify that the network targets have
been set. | [
"Used",
"in",
"backprop",
"()",
"to",
"verify",
"that",
"the",
"network",
"targets",
"have",
"been",
"set",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1608-L1618 |
Calysto/calysto | calysto/ai/conx.py | Network.RMSError | def RMSError(self):
"""
Returns Root Mean Squared Error for all output layers in this network.
"""
tss = 0.0
size = 0
for layer in self.layers:
if layer.type == 'Output':
tss += layer.TSSError()
size += layer.size
return... | python | def RMSError(self):
"""
Returns Root Mean Squared Error for all output layers in this network.
"""
tss = 0.0
size = 0
for layer in self.layers:
if layer.type == 'Output':
tss += layer.TSSError()
size += layer.size
return... | [
"def",
"RMSError",
"(",
"self",
")",
":",
"tss",
"=",
"0.0",
"size",
"=",
"0",
"for",
"layer",
"in",
"self",
".",
"layers",
":",
"if",
"layer",
".",
"type",
"==",
"'Output'",
":",
"tss",
"+=",
"layer",
".",
"TSSError",
"(",
")",
"size",
"+=",
"la... | Returns Root Mean Squared Error for all output layers in this network. | [
"Returns",
"Root",
"Mean",
"Squared",
"Error",
"for",
"all",
"output",
"layers",
"in",
"this",
"network",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1627-L1637 |
Calysto/calysto | calysto/ai/conx.py | Network.train | def train(self, sweeps=None, cont=0):
"""
Trains the network on the dataset till a stopping condition is
met. This stopping condition can be a limiting epoch or a percentage correct requirement.
"""
# check architecture
self.complete = 0
self.verifyArchitecture()
... | python | def train(self, sweeps=None, cont=0):
"""
Trains the network on the dataset till a stopping condition is
met. This stopping condition can be a limiting epoch or a percentage correct requirement.
"""
# check architecture
self.complete = 0
self.verifyArchitecture()
... | [
"def",
"train",
"(",
"self",
",",
"sweeps",
"=",
"None",
",",
"cont",
"=",
"0",
")",
":",
"# check architecture",
"self",
".",
"complete",
"=",
"0",
"self",
".",
"verifyArchitecture",
"(",
")",
"tssErr",
"=",
"0.0",
"rmsErr",
"=",
"0.0",
"totalCorrect",
... | Trains the network on the dataset till a stopping condition is
met. This stopping condition can be a limiting epoch or a percentage correct requirement. | [
"Trains",
"the",
"network",
"on",
"the",
"dataset",
"till",
"a",
"stopping",
"condition",
"is",
"met",
".",
"This",
"stopping",
"condition",
"can",
"be",
"a",
"limiting",
"epoch",
"or",
"a",
"percentage",
"correct",
"requirement",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1683-L1755 |
Calysto/calysto | calysto/ai/conx.py | Network.step | def step(self, **args):
"""
Network.step()
Does a single step. Calls propagate(), backprop(), and
change_weights() if learning is set.
Format for parameters: <layer name> = <activation/target list>
"""
if self.verbosity > 0:
print("Network.ste... | python | def step(self, **args):
"""
Network.step()
Does a single step. Calls propagate(), backprop(), and
change_weights() if learning is set.
Format for parameters: <layer name> = <activation/target list>
"""
if self.verbosity > 0:
print("Network.ste... | [
"def",
"step",
"(",
"self",
",",
"*",
"*",
"args",
")",
":",
"if",
"self",
".",
"verbosity",
">",
"0",
":",
"print",
"(",
"\"Network.step() called with:\"",
",",
"args",
")",
"# First, copy the values into either activations or targets:",
"retargs",
"=",
"self",
... | Network.step()
Does a single step. Calls propagate(), backprop(), and
change_weights() if learning is set.
Format for parameters: <layer name> = <activation/target list> | [
"Network",
".",
"step",
"()",
"Does",
"a",
"single",
"step",
".",
"Calls",
"propagate",
"()",
"backprop",
"()",
"and",
"change_weights",
"()",
"if",
"learning",
"is",
"set",
".",
"Format",
"for",
"parameters",
":",
"<layer",
"name",
">",
"=",
"<activation"... | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1766-L1812 |
Calysto/calysto | calysto/ai/conx.py | Network.sweep | def sweep(self):
"""
Runs through entire dataset.
Returns TSS error, total correct, total count, pcorrect (a dict of layer data)
"""
self.preSweep()
if self.loadOrder == []:
raise NetworkError('No loadOrder for the inputs. Make sure inputs are properly set.',... | python | def sweep(self):
"""
Runs through entire dataset.
Returns TSS error, total correct, total count, pcorrect (a dict of layer data)
"""
self.preSweep()
if self.loadOrder == []:
raise NetworkError('No loadOrder for the inputs. Make sure inputs are properly set.',... | [
"def",
"sweep",
"(",
"self",
")",
":",
"self",
".",
"preSweep",
"(",
")",
"if",
"self",
".",
"loadOrder",
"==",
"[",
"]",
":",
"raise",
"NetworkError",
"(",
"'No loadOrder for the inputs. Make sure inputs are properly set.'",
",",
"self",
".",
"loadOrder",
")",
... | Runs through entire dataset.
Returns TSS error, total correct, total count, pcorrect (a dict of layer data) | [
"Runs",
"through",
"entire",
"dataset",
".",
"Returns",
"TSS",
"error",
"total",
"correct",
"total",
"count",
"pcorrect",
"(",
"a",
"dict",
"of",
"layer",
"data",
")"
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1822-L1865 |
Calysto/calysto | calysto/ai/conx.py | Network.sweepCrossValidation | def sweepCrossValidation(self):
"""
sweepCrossValidation() will go through each of the crossvalidation input/targets.
The crossValidationCorpus is a list of dictionaries of input/targets
referenced by layername.
Example: ({"input": [0.0, 0.1], "output": [1.0]}, {"input": [0.5, 0.... | python | def sweepCrossValidation(self):
"""
sweepCrossValidation() will go through each of the crossvalidation input/targets.
The crossValidationCorpus is a list of dictionaries of input/targets
referenced by layername.
Example: ({"input": [0.0, 0.1], "output": [1.0]}, {"input": [0.5, 0.... | [
"def",
"sweepCrossValidation",
"(",
"self",
")",
":",
"# get learning value and then turn it off",
"oldLearning",
"=",
"self",
".",
"learning",
"self",
".",
"learning",
"=",
"0",
"tssError",
"=",
"0.0",
"totalCorrect",
"=",
"0",
"totalCount",
"=",
"0",
"totalPCorr... | sweepCrossValidation() will go through each of the crossvalidation input/targets.
The crossValidationCorpus is a list of dictionaries of input/targets
referenced by layername.
Example: ({"input": [0.0, 0.1], "output": [1.0]}, {"input": [0.5, 0.9], "output": [0.0]}) | [
"sweepCrossValidation",
"()",
"will",
"go",
"through",
"each",
"of",
"the",
"crossvalidation",
"input",
"/",
"targets",
".",
"The",
"crossValidationCorpus",
"is",
"a",
"list",
"of",
"dictionaries",
"of",
"input",
"/",
"targets",
"referenced",
"by",
"layername",
... | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1866-L1903 |
Calysto/calysto | calysto/ai/conx.py | Network.numConnects | def numConnects(self, layerName):
""" Number of incoming weights, including bias. Assumes fully connected. """
count = 0
if self[layerName].active:
count += 1 # 1 = bias
for connection in self.connections:
if connection.active and connection.fromLayer.act... | python | def numConnects(self, layerName):
""" Number of incoming weights, including bias. Assumes fully connected. """
count = 0
if self[layerName].active:
count += 1 # 1 = bias
for connection in self.connections:
if connection.active and connection.fromLayer.act... | [
"def",
"numConnects",
"(",
"self",
",",
"layerName",
")",
":",
"count",
"=",
"0",
"if",
"self",
"[",
"layerName",
"]",
".",
"active",
":",
"count",
"+=",
"1",
"# 1 = bias",
"for",
"connection",
"in",
"self",
".",
"connections",
":",
"if",
"connection",
... | Number of incoming weights, including bias. Assumes fully connected. | [
"Number",
"of",
"incoming",
"weights",
"including",
"bias",
".",
"Assumes",
"fully",
"connected",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1933-L1941 |
Calysto/calysto | calysto/ai/conx.py | Network.prop_from | def prop_from(self, startLayers):
"""
Start propagation from the layers in the list
startLayers. Make sure startLayers are initialized with the
desired activations. NO ERROR CHECKING.
"""
if self.verbosity > 2: print("Partially propagating network:")
# find all th... | python | def prop_from(self, startLayers):
"""
Start propagation from the layers in the list
startLayers. Make sure startLayers are initialized with the
desired activations. NO ERROR CHECKING.
"""
if self.verbosity > 2: print("Partially propagating network:")
# find all th... | [
"def",
"prop_from",
"(",
"self",
",",
"startLayers",
")",
":",
"if",
"self",
".",
"verbosity",
">",
"2",
":",
"print",
"(",
"\"Partially propagating network:\"",
")",
"# find all the layers involved in the propagation",
"propagateLayers",
"=",
"[",
"]",
"# propagateLa... | Start propagation from the layers in the list
startLayers. Make sure startLayers are initialized with the
desired activations. NO ERROR CHECKING. | [
"Start",
"propagation",
"from",
"the",
"layers",
"in",
"the",
"list",
"startLayers",
".",
"Make",
"sure",
"startLayers",
"are",
"initialized",
"with",
"the",
"desired",
"activations",
".",
"NO",
"ERROR",
"CHECKING",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1944-L1972 |
Calysto/calysto | calysto/ai/conx.py | Network.propagate | def propagate(self, **args):
"""
Propagates activation through the network. Optionally, takes input layer names
as keywords, and their associated activations. If input layer(s) are given, then
propagate() will return the output layer's activation. If there is more than
one output... | python | def propagate(self, **args):
"""
Propagates activation through the network. Optionally, takes input layer names
as keywords, and their associated activations. If input layer(s) are given, then
propagate() will return the output layer's activation. If there is more than
one output... | [
"def",
"propagate",
"(",
"self",
",",
"*",
"*",
"args",
")",
":",
"self",
".",
"prePropagate",
"(",
"*",
"*",
"args",
")",
"for",
"key",
"in",
"args",
":",
"layer",
"=",
"self",
".",
"getLayer",
"(",
"key",
")",
"if",
"layer",
".",
"kind",
"==",
... | Propagates activation through the network. Optionally, takes input layer names
as keywords, and their associated activations. If input layer(s) are given, then
propagate() will return the output layer's activation. If there is more than
one output layer, then a dictionary is returned.
E... | [
"Propagates",
"activation",
"through",
"the",
"network",
".",
"Optionally",
"takes",
"input",
"layer",
"names",
"as",
"keywords",
"and",
"their",
"associated",
"activations",
".",
"If",
"input",
"layer",
"(",
"s",
")",
"are",
"given",
"then",
"propagate",
"()"... | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L1973-L2039 |
Calysto/calysto | calysto/ai/conx.py | Network.propagateTo | def propagateTo(self, toLayer, **args):
"""
Propagates activation to a layer. Optionally, takes input layer names
as keywords, and their associated activations. Returns the toLayer's activation.
Examples:
>>> net = Network() # doctest: +ELLIPSIS
Conx using seed: ...
... | python | def propagateTo(self, toLayer, **args):
"""
Propagates activation to a layer. Optionally, takes input layer names
as keywords, and their associated activations. Returns the toLayer's activation.
Examples:
>>> net = Network() # doctest: +ELLIPSIS
Conx using seed: ...
... | [
"def",
"propagateTo",
"(",
"self",
",",
"toLayer",
",",
"*",
"*",
"args",
")",
":",
"for",
"layerName",
"in",
"args",
":",
"self",
"[",
"layerName",
"]",
".",
"activationSet",
"=",
"0",
"# force it to be ok",
"self",
"[",
"layerName",
"]",
".",
"copyActi... | Propagates activation to a layer. Optionally, takes input layer names
as keywords, and their associated activations. Returns the toLayer's activation.
Examples:
>>> net = Network() # doctest: +ELLIPSIS
Conx using seed: ...
>>> net.addLayers(2, 5, 1)
>>> len(net.propagat... | [
"Propagates",
"activation",
"to",
"a",
"layer",
".",
"Optionally",
"takes",
"input",
"layer",
"names",
"as",
"keywords",
"and",
"their",
"associated",
"activations",
".",
"Returns",
"the",
"toLayer",
"s",
"activation",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2040-L2070 |
Calysto/calysto | calysto/ai/conx.py | Network.propagateFrom | def propagateFrom(self, startLayer, **args):
"""
Propagates activation through the network. Optionally, takes input layer names
as keywords, and their associated activations. If input layer(s) are given, then
propagate() will return the output layer's activation. If there is more than
... | python | def propagateFrom(self, startLayer, **args):
"""
Propagates activation through the network. Optionally, takes input layer names
as keywords, and their associated activations. If input layer(s) are given, then
propagate() will return the output layer's activation. If there is more than
... | [
"def",
"propagateFrom",
"(",
"self",
",",
"startLayer",
",",
"*",
"*",
"args",
")",
":",
"for",
"layerName",
"in",
"args",
":",
"self",
"[",
"layerName",
"]",
".",
"copyActivations",
"(",
"args",
"[",
"layerName",
"]",
")",
"# initialize netinput:",
"start... | Propagates activation through the network. Optionally, takes input layer names
as keywords, and their associated activations. If input layer(s) are given, then
propagate() will return the output layer's activation. If there is more than
one output layer, then a dictionary is returned.
E... | [
"Propagates",
"activation",
"through",
"the",
"network",
".",
"Optionally",
"takes",
"input",
"layer",
"names",
"as",
"keywords",
"and",
"their",
"associated",
"activations",
".",
"If",
"input",
"layer",
"(",
"s",
")",
"are",
"given",
"then",
"propagate",
"()"... | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2071-L2124 |
Calysto/calysto | calysto/ai/conx.py | Network.activationFunctionASIG | def activationFunctionASIG(self, x):
"""
Determine the activation of a node based on that nodes net input.
"""
def act(v):
if v < -15.0: return 0.0
elif v > 15.0: return 1.0
else: return 1.0 / (1.0 + Numeric.exp(-v))
return Numeric.array(lis... | python | def activationFunctionASIG(self, x):
"""
Determine the activation of a node based on that nodes net input.
"""
def act(v):
if v < -15.0: return 0.0
elif v > 15.0: return 1.0
else: return 1.0 / (1.0 + Numeric.exp(-v))
return Numeric.array(lis... | [
"def",
"activationFunctionASIG",
"(",
"self",
",",
"x",
")",
":",
"def",
"act",
"(",
"v",
")",
":",
"if",
"v",
"<",
"-",
"15.0",
":",
"return",
"0.0",
"elif",
"v",
">",
"15.0",
":",
"return",
"1.0",
"else",
":",
"return",
"1.0",
"/",
"(",
"1.0",
... | Determine the activation of a node based on that nodes net input. | [
"Determine",
"the",
"activation",
"of",
"a",
"node",
"based",
"on",
"that",
"nodes",
"net",
"input",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2128-L2136 |
Calysto/calysto | calysto/ai/conx.py | Network.actDerivASIG | def actDerivASIG(self, x):
"""
Only works on scalars.
"""
def act(v):
if v < -15.0: return 0.0
elif v > 15.0: return 1.0
else: return 1.0 / (1.0 + Numeric.exp(-v))
return (act(x) * (1.0 - act(x))) + self.sigmoid_prime_offset | python | def actDerivASIG(self, x):
"""
Only works on scalars.
"""
def act(v):
if v < -15.0: return 0.0
elif v > 15.0: return 1.0
else: return 1.0 / (1.0 + Numeric.exp(-v))
return (act(x) * (1.0 - act(x))) + self.sigmoid_prime_offset | [
"def",
"actDerivASIG",
"(",
"self",
",",
"x",
")",
":",
"def",
"act",
"(",
"v",
")",
":",
"if",
"v",
"<",
"-",
"15.0",
":",
"return",
"0.0",
"elif",
"v",
">",
"15.0",
":",
"return",
"1.0",
"else",
":",
"return",
"1.0",
"/",
"(",
"1.0",
"+",
"... | Only works on scalars. | [
"Only",
"works",
"on",
"scalars",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2143-L2151 |
Calysto/calysto | calysto/ai/conx.py | Network.useTanhActivationFunction | def useTanhActivationFunction(self):
"""
Change the network to use the hyperbolic tangent activation function for all layers.
Must be called after all layers have been added.
"""
self.activationFunction = self.activationFunctionTANH
self.ACTPRIME = self.ACTPRIMETANH
... | python | def useTanhActivationFunction(self):
"""
Change the network to use the hyperbolic tangent activation function for all layers.
Must be called after all layers have been added.
"""
self.activationFunction = self.activationFunctionTANH
self.ACTPRIME = self.ACTPRIMETANH
... | [
"def",
"useTanhActivationFunction",
"(",
"self",
")",
":",
"self",
".",
"activationFunction",
"=",
"self",
".",
"activationFunctionTANH",
"self",
".",
"ACTPRIME",
"=",
"self",
".",
"ACTPRIMETANH",
"self",
".",
"actDeriv",
"=",
"self",
".",
"actDerivTANH",
"for",... | Change the network to use the hyperbolic tangent activation function for all layers.
Must be called after all layers have been added. | [
"Change",
"the",
"network",
"to",
"use",
"the",
"hyperbolic",
"tangent",
"activation",
"function",
"for",
"all",
"layers",
".",
"Must",
"be",
"called",
"after",
"all",
"layers",
"have",
"been",
"added",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2186-L2196 |
Calysto/calysto | calysto/ai/conx.py | Network.useFahlmanActivationFunction | def useFahlmanActivationFunction(self):
"""
Change the network to use Fahlman's default activation function for all layers.
Must be called after all layers have been added.
"""
self.activationFunction = self.activationFunctionFahlman
self.ACTPRIME = self.ACTPRIME_Fahlman
... | python | def useFahlmanActivationFunction(self):
"""
Change the network to use Fahlman's default activation function for all layers.
Must be called after all layers have been added.
"""
self.activationFunction = self.activationFunctionFahlman
self.ACTPRIME = self.ACTPRIME_Fahlman
... | [
"def",
"useFahlmanActivationFunction",
"(",
"self",
")",
":",
"self",
".",
"activationFunction",
"=",
"self",
".",
"activationFunctionFahlman",
"self",
".",
"ACTPRIME",
"=",
"self",
".",
"ACTPRIME_Fahlman",
"self",
".",
"actDeriv",
"=",
"self",
".",
"actDerivFahlm... | Change the network to use Fahlman's default activation function for all layers.
Must be called after all layers have been added. | [
"Change",
"the",
"network",
"to",
"use",
"Fahlman",
"s",
"default",
"activation",
"function",
"for",
"all",
"layers",
".",
"Must",
"be",
"called",
"after",
"all",
"layers",
"have",
"been",
"added",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2197-L2207 |
Calysto/calysto | calysto/ai/conx.py | Network.backprop | def backprop(self, **args):
"""
Computes error and wed for back propagation of error.
"""
retval = self.compute_error(**args)
if self.learning:
self.compute_wed()
return retval | python | def backprop(self, **args):
"""
Computes error and wed for back propagation of error.
"""
retval = self.compute_error(**args)
if self.learning:
self.compute_wed()
return retval | [
"def",
"backprop",
"(",
"self",
",",
"*",
"*",
"args",
")",
":",
"retval",
"=",
"self",
".",
"compute_error",
"(",
"*",
"*",
"args",
")",
"if",
"self",
".",
"learning",
":",
"self",
".",
"compute_wed",
"(",
")",
"return",
"retval"
] | Computes error and wed for back propagation of error. | [
"Computes",
"error",
"and",
"wed",
"for",
"back",
"propagation",
"of",
"error",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2213-L2220 |
Calysto/calysto | calysto/ai/conx.py | Network.deltaWeight | def deltaWeight(self, e, wed, m, dweightLast, wedLast, w, n):
"""
e - learning rate
wed - weight error delta vector (slope)
m - momentum
dweightLast - previous dweight vector (slope)
wedLast - only used in quickprop; last weight error delta vector
w - weight vecto... | python | def deltaWeight(self, e, wed, m, dweightLast, wedLast, w, n):
"""
e - learning rate
wed - weight error delta vector (slope)
m - momentum
dweightLast - previous dweight vector (slope)
wedLast - only used in quickprop; last weight error delta vector
w - weight vecto... | [
"def",
"deltaWeight",
"(",
"self",
",",
"e",
",",
"wed",
",",
"m",
",",
"dweightLast",
",",
"wedLast",
",",
"w",
",",
"n",
")",
":",
"#print \"WEIGHT = \", w",
"shrinkFactor",
"=",
"self",
".",
"mu",
"/",
"(",
"1.0",
"+",
"self",
".",
"mu",
")",
"i... | e - learning rate
wed - weight error delta vector (slope)
m - momentum
dweightLast - previous dweight vector (slope)
wedLast - only used in quickprop; last weight error delta vector
w - weight vector
n - fan-in, number of connections coming in (counts bias, too) | [
"e",
"-",
"learning",
"rate",
"wed",
"-",
"weight",
"error",
"delta",
"vector",
"(",
"slope",
")",
"m",
"-",
"momentum",
"dweightLast",
"-",
"previous",
"dweight",
"vector",
"(",
"slope",
")",
"wedLast",
"-",
"only",
"used",
"in",
"quickprop",
";",
"last... | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2221-L2272 |
Calysto/calysto | calysto/ai/conx.py | Network.change_weights | def change_weights(self):
"""
Changes the weights according to the error values calculated
during backprop(). Learning must be set.
"""
dw_count, dw_sum = 0, 0.0
if len(self.cacheLayers) != 0:
changeLayers = self.cacheLayers
else:
changeLay... | python | def change_weights(self):
"""
Changes the weights according to the error values calculated
during backprop(). Learning must be set.
"""
dw_count, dw_sum = 0, 0.0
if len(self.cacheLayers) != 0:
changeLayers = self.cacheLayers
else:
changeLay... | [
"def",
"change_weights",
"(",
"self",
")",
":",
"dw_count",
",",
"dw_sum",
"=",
"0",
",",
"0.0",
"if",
"len",
"(",
"self",
".",
"cacheLayers",
")",
"!=",
"0",
":",
"changeLayers",
"=",
"self",
".",
"cacheLayers",
"else",
":",
"changeLayers",
"=",
"self... | Changes the weights according to the error values calculated
during backprop(). Learning must be set. | [
"Changes",
"the",
"weights",
"according",
"to",
"the",
"error",
"values",
"calculated",
"during",
"backprop",
"()",
".",
"Learning",
"must",
"be",
"set",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2273-L2346 |
Calysto/calysto | calysto/ai/conx.py | Network.errorFunction | def errorFunction(self, t, a):
"""
Using a hyperbolic arctan on the error slightly exaggerates
the actual error non-linearly. Return t - a to just use the difference.
t - target vector
a - activation vector
"""
def difference(v):
if not self.hyperbolic... | python | def errorFunction(self, t, a):
"""
Using a hyperbolic arctan on the error slightly exaggerates
the actual error non-linearly. Return t - a to just use the difference.
t - target vector
a - activation vector
"""
def difference(v):
if not self.hyperbolic... | [
"def",
"errorFunction",
"(",
"self",
",",
"t",
",",
"a",
")",
":",
"def",
"difference",
"(",
"v",
")",
":",
"if",
"not",
"self",
".",
"hyperbolicError",
":",
"#if -0.1 < v < 0.1: return 0.0",
"#else:",
"return",
"v",
"else",
":",
"if",
"v",
"<",
"-",
"... | Using a hyperbolic arctan on the error slightly exaggerates
the actual error non-linearly. Return t - a to just use the difference.
t - target vector
a - activation vector | [
"Using",
"a",
"hyperbolic",
"arctan",
"on",
"the",
"error",
"slightly",
"exaggerates",
"the",
"actual",
"error",
"non",
"-",
"linearly",
".",
"Return",
"t",
"-",
"a",
"to",
"just",
"use",
"the",
"difference",
".",
"t",
"-",
"target",
"vector",
"a",
"-",
... | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2348-L2365 |
Calysto/calysto | calysto/ai/conx.py | Network.ce_init | def ce_init(self):
"""
Initializes error computation. Calculates error for output
layers and initializes hidden layer error to zero.
"""
retval = 0.0; correct = 0; totalCount = 0
for layer in self.layers:
if layer.active:
if layer.type == 'Outp... | python | def ce_init(self):
"""
Initializes error computation. Calculates error for output
layers and initializes hidden layer error to zero.
"""
retval = 0.0; correct = 0; totalCount = 0
for layer in self.layers:
if layer.active:
if layer.type == 'Outp... | [
"def",
"ce_init",
"(",
"self",
")",
":",
"retval",
"=",
"0.0",
"correct",
"=",
"0",
"totalCount",
"=",
"0",
"for",
"layer",
"in",
"self",
".",
"layers",
":",
"if",
"layer",
".",
"active",
":",
"if",
"layer",
".",
"type",
"==",
"'Output'",
":",
"lay... | Initializes error computation. Calculates error for output
layers and initializes hidden layer error to zero. | [
"Initializes",
"error",
"computation",
".",
"Calculates",
"error",
"for",
"output",
"layers",
"and",
"initializes",
"hidden",
"layer",
"error",
"to",
"zero",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2367-L2383 |
Calysto/calysto | calysto/ai/conx.py | Network.compute_error | def compute_error(self, **args):
"""
Computes error for all non-output layers backwards through all
projections.
"""
for key in args:
layer = self.getLayer(key)
if layer.kind == 'Output':
self.copyTargets(layer, args[key])
self.veri... | python | def compute_error(self, **args):
"""
Computes error for all non-output layers backwards through all
projections.
"""
for key in args:
layer = self.getLayer(key)
if layer.kind == 'Output':
self.copyTargets(layer, args[key])
self.veri... | [
"def",
"compute_error",
"(",
"self",
",",
"*",
"*",
"args",
")",
":",
"for",
"key",
"in",
"args",
":",
"layer",
"=",
"self",
".",
"getLayer",
"(",
"key",
")",
"if",
"layer",
".",
"kind",
"==",
"'Output'",
":",
"self",
".",
"copyTargets",
"(",
"laye... | Computes error for all non-output layers backwards through all
projections. | [
"Computes",
"error",
"for",
"all",
"non",
"-",
"output",
"layers",
"backwards",
"through",
"all",
"projections",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2384-L2409 |
Calysto/calysto | calysto/ai/conx.py | Network.compute_wed | def compute_wed(self):
"""
Computes weight error derivative for all connections in
self.connections starting with the last connection.
"""
if len(self.cacheConnections) != 0:
changeConnections = self.cacheConnections
else:
changeConnections = self.... | python | def compute_wed(self):
"""
Computes weight error derivative for all connections in
self.connections starting with the last connection.
"""
if len(self.cacheConnections) != 0:
changeConnections = self.cacheConnections
else:
changeConnections = self.... | [
"def",
"compute_wed",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"cacheConnections",
")",
"!=",
"0",
":",
"changeConnections",
"=",
"self",
".",
"cacheConnections",
"else",
":",
"changeConnections",
"=",
"self",
".",
"connections",
"for",
"connect... | Computes weight error derivative for all connections in
self.connections starting with the last connection. | [
"Computes",
"weight",
"error",
"derivative",
"for",
"all",
"connections",
"in",
"self",
".",
"connections",
"starting",
"with",
"the",
"last",
"connection",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2438-L2457 |
Calysto/calysto | calysto/ai/conx.py | Network.toString | def toString(self):
"""
Returns the network layers as a string.
"""
output = ""
for layer in reverse(self.layers):
output += layer.toString()
return output | python | def toString(self):
"""
Returns the network layers as a string.
"""
output = ""
for layer in reverse(self.layers):
output += layer.toString()
return output | [
"def",
"toString",
"(",
"self",
")",
":",
"output",
"=",
"\"\"",
"for",
"layer",
"in",
"reverse",
"(",
"self",
".",
"layers",
")",
":",
"output",
"+=",
"layer",
".",
"toString",
"(",
")",
"return",
"output"
] | Returns the network layers as a string. | [
"Returns",
"the",
"network",
"layers",
"as",
"a",
"string",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2469-L2476 |
Calysto/calysto | calysto/ai/conx.py | Network.display | def display(self):
"""
Displays the network to the screen.
"""
print("Display network '" + self.name + "':")
size = list(range(len(self.layers)))
size.reverse()
for i in size:
if self.layers[i].active:
self.layers[i].display()
... | python | def display(self):
"""
Displays the network to the screen.
"""
print("Display network '" + self.name + "':")
size = list(range(len(self.layers)))
size.reverse()
for i in size:
if self.layers[i].active:
self.layers[i].display()
... | [
"def",
"display",
"(",
"self",
")",
":",
"print",
"(",
"\"Display network '\"",
"+",
"self",
".",
"name",
"+",
"\"':\"",
")",
"size",
"=",
"list",
"(",
"range",
"(",
"len",
"(",
"self",
".",
"layers",
")",
")",
")",
"size",
".",
"reverse",
"(",
")"... | Displays the network to the screen. | [
"Displays",
"the",
"network",
"to",
"the",
"screen",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2544-L2578 |
Calysto/calysto | calysto/ai/conx.py | Network.arrayify | def arrayify(self):
"""
Returns an array of node bias values and connection weights
for use in a GA.
"""
gene = []
for layer in self.layers:
if layer.type != 'Input':
for i in range(layer.size):
gene.append( layer.weight[i] ... | python | def arrayify(self):
"""
Returns an array of node bias values and connection weights
for use in a GA.
"""
gene = []
for layer in self.layers:
if layer.type != 'Input':
for i in range(layer.size):
gene.append( layer.weight[i] ... | [
"def",
"arrayify",
"(",
"self",
")",
":",
"gene",
"=",
"[",
"]",
"for",
"layer",
"in",
"self",
".",
"layers",
":",
"if",
"layer",
".",
"type",
"!=",
"'Input'",
":",
"for",
"i",
"in",
"range",
"(",
"layer",
".",
"size",
")",
":",
"gene",
".",
"a... | Returns an array of node bias values and connection weights
for use in a GA. | [
"Returns",
"an",
"array",
"of",
"node",
"bias",
"values",
"and",
"connection",
"weights",
"for",
"use",
"in",
"a",
"GA",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2581-L2595 |
Calysto/calysto | calysto/ai/conx.py | Network.unArrayify | def unArrayify(self, gene):
"""
Copies gene bias values and weights to network bias values and
weights.
"""
g = 0
# if gene is too small an IndexError will be thrown
for layer in self.layers:
if layer.type != 'Input':
for i in range(lay... | python | def unArrayify(self, gene):
"""
Copies gene bias values and weights to network bias values and
weights.
"""
g = 0
# if gene is too small an IndexError will be thrown
for layer in self.layers:
if layer.type != 'Input':
for i in range(lay... | [
"def",
"unArrayify",
"(",
"self",
",",
"gene",
")",
":",
"g",
"=",
"0",
"# if gene is too small an IndexError will be thrown",
"for",
"layer",
"in",
"self",
".",
"layers",
":",
"if",
"layer",
".",
"type",
"!=",
"'Input'",
":",
"for",
"i",
"in",
"range",
"(... | Copies gene bias values and weights to network bias values and
weights. | [
"Copies",
"gene",
"bias",
"values",
"and",
"weights",
"to",
"network",
"bias",
"values",
"and",
"weights",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2596-L2615 |
Calysto/calysto | calysto/ai/conx.py | Network.saveWeightsToFile | def saveWeightsToFile(self, filename, mode='pickle', counter=None):
"""
Deprecated. Use saveWeights instead.
"""
self.saveWeights(filename, mode, counter) | python | def saveWeightsToFile(self, filename, mode='pickle', counter=None):
"""
Deprecated. Use saveWeights instead.
"""
self.saveWeights(filename, mode, counter) | [
"def",
"saveWeightsToFile",
"(",
"self",
",",
"filename",
",",
"mode",
"=",
"'pickle'",
",",
"counter",
"=",
"None",
")",
":",
"self",
".",
"saveWeights",
"(",
"filename",
",",
"mode",
",",
"counter",
")"
] | Deprecated. Use saveWeights instead. | [
"Deprecated",
".",
"Use",
"saveWeights",
"instead",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2635-L2639 |
Calysto/calysto | calysto/ai/conx.py | Network.saveWeights | def saveWeights(self, filename, mode='pickle', counter=None):
"""
Saves weights to file in pickle, plain, or tlearn mode.
"""
# modes: pickle/conx, plain, tlearn
if "?" in filename: # replace ? pattern in filename with epoch number
import re
char = "?"
... | python | def saveWeights(self, filename, mode='pickle', counter=None):
"""
Saves weights to file in pickle, plain, or tlearn mode.
"""
# modes: pickle/conx, plain, tlearn
if "?" in filename: # replace ? pattern in filename with epoch number
import re
char = "?"
... | [
"def",
"saveWeights",
"(",
"self",
",",
"filename",
",",
"mode",
"=",
"'pickle'",
",",
"counter",
"=",
"None",
")",
":",
"# modes: pickle/conx, plain, tlearn",
"if",
"\"?\"",
"in",
"filename",
":",
"# replace ? pattern in filename with epoch number",
"import",
"re",
... | Saves weights to file in pickle, plain, or tlearn mode. | [
"Saves",
"weights",
"to",
"file",
"in",
"pickle",
"plain",
"or",
"tlearn",
"mode",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2641-L2707 |
Calysto/calysto | calysto/ai/conx.py | Network.loadWeights | def loadWeights(self, filename, mode='pickle'):
"""
Loads weights from a file in pickle, plain, or tlearn mode.
"""
# modes: pickle, plain/conx, tlearn
if mode == 'pickle':
import pickle
fp = open(filename, "r")
mylist = pickle.load(fp)
... | python | def loadWeights(self, filename, mode='pickle'):
"""
Loads weights from a file in pickle, plain, or tlearn mode.
"""
# modes: pickle, plain/conx, tlearn
if mode == 'pickle':
import pickle
fp = open(filename, "r")
mylist = pickle.load(fp)
... | [
"def",
"loadWeights",
"(",
"self",
",",
"filename",
",",
"mode",
"=",
"'pickle'",
")",
":",
"# modes: pickle, plain/conx, tlearn",
"if",
"mode",
"==",
"'pickle'",
":",
"import",
"pickle",
"fp",
"=",
"open",
"(",
"filename",
",",
"\"r\"",
")",
"mylist",
"=",
... | Loads weights from a file in pickle, plain, or tlearn mode. | [
"Loads",
"weights",
"from",
"a",
"file",
"in",
"pickle",
"plain",
"or",
"tlearn",
"mode",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2715-L2831 |
Calysto/calysto | calysto/ai/conx.py | Network.saveNetwork | def saveNetwork(self, filename, makeWrapper = 1, mode = "pickle", counter = None):
"""
Saves network to file using pickle.
"""
self.saveNetworkToFile(filename, makeWrapper, mode, counter) | python | def saveNetwork(self, filename, makeWrapper = 1, mode = "pickle", counter = None):
"""
Saves network to file using pickle.
"""
self.saveNetworkToFile(filename, makeWrapper, mode, counter) | [
"def",
"saveNetwork",
"(",
"self",
",",
"filename",
",",
"makeWrapper",
"=",
"1",
",",
"mode",
"=",
"\"pickle\"",
",",
"counter",
"=",
"None",
")",
":",
"self",
".",
"saveNetworkToFile",
"(",
"filename",
",",
"makeWrapper",
",",
"mode",
",",
"counter",
"... | Saves network to file using pickle. | [
"Saves",
"network",
"to",
"file",
"using",
"pickle",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2833-L2837 |
Calysto/calysto | calysto/ai/conx.py | Network.saveNetworkToFile | def saveNetworkToFile(self, filename, makeWrapper = 1, mode = "pickle", counter = None):
"""
Deprecated.
"""
if "?" in filename: # replace ? pattern in filename with epoch number
import re
char = "?"
match = re.search(re.escape(char) + "+", filename)
... | python | def saveNetworkToFile(self, filename, makeWrapper = 1, mode = "pickle", counter = None):
"""
Deprecated.
"""
if "?" in filename: # replace ? pattern in filename with epoch number
import re
char = "?"
match = re.search(re.escape(char) + "+", filename)
... | [
"def",
"saveNetworkToFile",
"(",
"self",
",",
"filename",
",",
"makeWrapper",
"=",
"1",
",",
"mode",
"=",
"\"pickle\"",
",",
"counter",
"=",
"None",
")",
":",
"if",
"\"?\"",
"in",
"filename",
":",
"# replace ? pattern in filename with epoch number",
"import",
"r... | Deprecated. | [
"Deprecated",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2839-L2899 |
Calysto/calysto | calysto/ai/conx.py | Network.loadVectors | def loadVectors(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1, patterned = 0):
"""
Load a set of vectors from a file. Takes a filename, list of cols
you want (or None for all), get every everyNrows (or 1 for no
skipping), and a delimeter.
... | python | def loadVectors(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1, patterned = 0):
"""
Load a set of vectors from a file. Takes a filename, list of cols
you want (or None for all), get every everyNrows (or 1 for no
skipping), and a delimeter.
... | [
"def",
"loadVectors",
"(",
"self",
",",
"filename",
",",
"cols",
"=",
"None",
",",
"everyNrows",
"=",
"1",
",",
"delim",
"=",
"' '",
",",
"checkEven",
"=",
"1",
",",
"patterned",
"=",
"0",
")",
":",
"return",
"self",
".",
"loadVectorsFromFile",
"(",
... | Load a set of vectors from a file. Takes a filename, list of cols
you want (or None for all), get every everyNrows (or 1 for no
skipping), and a delimeter. | [
"Load",
"a",
"set",
"of",
"vectors",
"from",
"a",
"file",
".",
"Takes",
"a",
"filename",
"list",
"of",
"cols",
"you",
"want",
"(",
"or",
"None",
"for",
"all",
")",
"get",
"every",
"everyNrows",
"(",
"or",
"1",
"for",
"no",
"skipping",
")",
"and",
"... | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2901-L2909 |
Calysto/calysto | calysto/ai/conx.py | Network.loadVectorsFromFile | def loadVectorsFromFile(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1, patterned = 0):
"""
Deprecated.
"""
fp = open(filename, "r")
line = fp.readline()
lineno = 0
lastLength = None
data = []
wh... | python | def loadVectorsFromFile(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1, patterned = 0):
"""
Deprecated.
"""
fp = open(filename, "r")
line = fp.readline()
lineno = 0
lastLength = None
data = []
wh... | [
"def",
"loadVectorsFromFile",
"(",
"self",
",",
"filename",
",",
"cols",
"=",
"None",
",",
"everyNrows",
"=",
"1",
",",
"delim",
"=",
"' '",
",",
"checkEven",
"=",
"1",
",",
"patterned",
"=",
"0",
")",
":",
"fp",
"=",
"open",
"(",
"filename",
",",
... | Deprecated. | [
"Deprecated",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2911-L2945 |
Calysto/calysto | calysto/ai/conx.py | Network.loadInputPatterns | def loadInputPatterns(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Loads inputs as patterns from file.
"""
self.loadInputPatternsFromFile(filename, cols, everyNrows,
delim, checkEven) | python | def loadInputPatterns(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Loads inputs as patterns from file.
"""
self.loadInputPatternsFromFile(filename, cols, everyNrows,
delim, checkEven) | [
"def",
"loadInputPatterns",
"(",
"self",
",",
"filename",
",",
"cols",
"=",
"None",
",",
"everyNrows",
"=",
"1",
",",
"delim",
"=",
"' '",
",",
"checkEven",
"=",
"1",
")",
":",
"self",
".",
"loadInputPatternsFromFile",
"(",
"filename",
",",
"cols",
",",
... | Loads inputs as patterns from file. | [
"Loads",
"inputs",
"as",
"patterns",
"from",
"file",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2947-L2953 |
Calysto/calysto | calysto/ai/conx.py | Network.loadInputPatternsFromFile | def loadInputPatternsFromFile(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Deprecated.
"""
self.inputs = self.loadVectors(filename, cols, everyNrows, delim, checkEven, patterned = 1)
self.loadOrder = [0] * len(sel... | python | def loadInputPatternsFromFile(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Deprecated.
"""
self.inputs = self.loadVectors(filename, cols, everyNrows, delim, checkEven, patterned = 1)
self.loadOrder = [0] * len(sel... | [
"def",
"loadInputPatternsFromFile",
"(",
"self",
",",
"filename",
",",
"cols",
"=",
"None",
",",
"everyNrows",
"=",
"1",
",",
"delim",
"=",
"' '",
",",
"checkEven",
"=",
"1",
")",
":",
"self",
".",
"inputs",
"=",
"self",
".",
"loadVectors",
"(",
"filen... | Deprecated. | [
"Deprecated",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2955-L2963 |
Calysto/calysto | calysto/ai/conx.py | Network.loadInputs | def loadInputs(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Loads inputs from file. Patterning is lost.
"""
self.loadInputsFromFile(filename, cols, everyNrows,
delim, checkEven) | python | def loadInputs(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Loads inputs from file. Patterning is lost.
"""
self.loadInputsFromFile(filename, cols, everyNrows,
delim, checkEven) | [
"def",
"loadInputs",
"(",
"self",
",",
"filename",
",",
"cols",
"=",
"None",
",",
"everyNrows",
"=",
"1",
",",
"delim",
"=",
"' '",
",",
"checkEven",
"=",
"1",
")",
":",
"self",
".",
"loadInputsFromFile",
"(",
"filename",
",",
"cols",
",",
"everyNrows"... | Loads inputs from file. Patterning is lost. | [
"Loads",
"inputs",
"from",
"file",
".",
"Patterning",
"is",
"lost",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2965-L2971 |
Calysto/calysto | calysto/ai/conx.py | Network.saveInputsToFile | def saveInputsToFile(self, filename):
"""
Deprecated.
"""
fp = open(filename, 'w')
for input in self.inputs:
vec = self.replacePatterns(input)
for item in vec:
fp.write("%f " % item)
fp.write("\n") | python | def saveInputsToFile(self, filename):
"""
Deprecated.
"""
fp = open(filename, 'w')
for input in self.inputs:
vec = self.replacePatterns(input)
for item in vec:
fp.write("%f " % item)
fp.write("\n") | [
"def",
"saveInputsToFile",
"(",
"self",
",",
"filename",
")",
":",
"fp",
"=",
"open",
"(",
"filename",
",",
"'w'",
")",
"for",
"input",
"in",
"self",
".",
"inputs",
":",
"vec",
"=",
"self",
".",
"replacePatterns",
"(",
"input",
")",
"for",
"item",
"i... | Deprecated. | [
"Deprecated",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L2989-L2998 |
Calysto/calysto | calysto/ai/conx.py | Network.loadTargets | def loadTargets(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Loads targets from file.
"""
self.loadTargetsFromFile(filename, cols, everyNrows,
delim, checkEven) | python | def loadTargets(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Loads targets from file.
"""
self.loadTargetsFromFile(filename, cols, everyNrows,
delim, checkEven) | [
"def",
"loadTargets",
"(",
"self",
",",
"filename",
",",
"cols",
"=",
"None",
",",
"everyNrows",
"=",
"1",
",",
"delim",
"=",
"' '",
",",
"checkEven",
"=",
"1",
")",
":",
"self",
".",
"loadTargetsFromFile",
"(",
"filename",
",",
"cols",
",",
"everyNrow... | Loads targets from file. | [
"Loads",
"targets",
"from",
"file",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3000-L3006 |
Calysto/calysto | calysto/ai/conx.py | Network.loadTargetsFromFile | def loadTargetsFromFile(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Loads targets from file.
"""
self.targets = self.loadVectors(filename, cols, everyNrows,
delim, checkEven) | python | def loadTargetsFromFile(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Loads targets from file.
"""
self.targets = self.loadVectors(filename, cols, everyNrows,
delim, checkEven) | [
"def",
"loadTargetsFromFile",
"(",
"self",
",",
"filename",
",",
"cols",
"=",
"None",
",",
"everyNrows",
"=",
"1",
",",
"delim",
"=",
"' '",
",",
"checkEven",
"=",
"1",
")",
":",
"self",
".",
"targets",
"=",
"self",
".",
"loadVectors",
"(",
"filename",... | Loads targets from file. | [
"Loads",
"targets",
"from",
"file",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3008-L3014 |
Calysto/calysto | calysto/ai/conx.py | Network.loadTargetPatterns | def loadTargetPatterns(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Loads targets as patterns from file.
"""
self.loadTargetPatternssFromFile(filename, cols, everyNrows,
delim, checkEven... | python | def loadTargetPatterns(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Loads targets as patterns from file.
"""
self.loadTargetPatternssFromFile(filename, cols, everyNrows,
delim, checkEven... | [
"def",
"loadTargetPatterns",
"(",
"self",
",",
"filename",
",",
"cols",
"=",
"None",
",",
"everyNrows",
"=",
"1",
",",
"delim",
"=",
"' '",
",",
"checkEven",
"=",
"1",
")",
":",
"self",
".",
"loadTargetPatternssFromFile",
"(",
"filename",
",",
"cols",
",... | Loads targets as patterns from file. | [
"Loads",
"targets",
"as",
"patterns",
"from",
"file",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3016-L3022 |
Calysto/calysto | calysto/ai/conx.py | Network.loadTargetPatternsFromFile | def loadTargetPatternsFromFile(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Deprecated.
"""
self.targets = self.loadVectors(filename, cols, everyNrows,
delim, checkEven, patterned=... | python | def loadTargetPatternsFromFile(self, filename, cols = None, everyNrows = 1,
delim = ' ', checkEven = 1):
"""
Deprecated.
"""
self.targets = self.loadVectors(filename, cols, everyNrows,
delim, checkEven, patterned=... | [
"def",
"loadTargetPatternsFromFile",
"(",
"self",
",",
"filename",
",",
"cols",
"=",
"None",
",",
"everyNrows",
"=",
"1",
",",
"delim",
"=",
"' '",
",",
"checkEven",
"=",
"1",
")",
":",
"self",
".",
"targets",
"=",
"self",
".",
"loadVectors",
"(",
"fil... | Deprecated. | [
"Deprecated",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3024-L3030 |
Calysto/calysto | calysto/ai/conx.py | Network.saveTargetsToFile | def saveTargetsToFile(self, filename):
"""
Deprecated.
"""
fp = open(filename, 'w')
for target in self.targets:
vec = self.replacePatterns(target)
for item in vec:
fp.write("%f " % item)
fp.write("\n") | python | def saveTargetsToFile(self, filename):
"""
Deprecated.
"""
fp = open(filename, 'w')
for target in self.targets:
vec = self.replacePatterns(target)
for item in vec:
fp.write("%f " % item)
fp.write("\n") | [
"def",
"saveTargetsToFile",
"(",
"self",
",",
"filename",
")",
":",
"fp",
"=",
"open",
"(",
"filename",
",",
"'w'",
")",
"for",
"target",
"in",
"self",
".",
"targets",
":",
"vec",
"=",
"self",
".",
"replacePatterns",
"(",
"target",
")",
"for",
"item",
... | Deprecated. | [
"Deprecated",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3038-L3047 |
Calysto/calysto | calysto/ai/conx.py | Network.saveDataToFile | def saveDataToFile(self, filename):
"""
Deprecated.
"""
fp = open(filename, 'w')
for i in range(len(self.inputs)):
try:
vec = self.replacePatterns(self.inputs[i])
for item in vec:
fp.write("%f " % item)
e... | python | def saveDataToFile(self, filename):
"""
Deprecated.
"""
fp = open(filename, 'w')
for i in range(len(self.inputs)):
try:
vec = self.replacePatterns(self.inputs[i])
for item in vec:
fp.write("%f " % item)
e... | [
"def",
"saveDataToFile",
"(",
"self",
",",
"filename",
")",
":",
"fp",
"=",
"open",
"(",
"filename",
",",
"'w'",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"inputs",
")",
")",
":",
"try",
":",
"vec",
"=",
"self",
".",
"replaceP... | Deprecated. | [
"Deprecated",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3055-L3073 |
Calysto/calysto | calysto/ai/conx.py | Network.loadDataFromFile | def loadDataFromFile(self, filename, ocnt = -1):
"""
Deprecated.
"""
if ocnt == -1:
ocnt = int(self.layers[len(self.layers) - 1].size)
fp = open(filename, 'r')
line = fp.readline()
self.targets = []
self.inputs = []
while line:
... | python | def loadDataFromFile(self, filename, ocnt = -1):
"""
Deprecated.
"""
if ocnt == -1:
ocnt = int(self.layers[len(self.layers) - 1].size)
fp = open(filename, 'r')
line = fp.readline()
self.targets = []
self.inputs = []
while line:
... | [
"def",
"loadDataFromFile",
"(",
"self",
",",
"filename",
",",
"ocnt",
"=",
"-",
"1",
")",
":",
"if",
"ocnt",
"==",
"-",
"1",
":",
"ocnt",
"=",
"int",
"(",
"self",
".",
"layers",
"[",
"len",
"(",
"self",
".",
"layers",
")",
"-",
"1",
"]",
".",
... | Deprecated. | [
"Deprecated",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3081-L3100 |
Calysto/calysto | calysto/ai/conx.py | Network.lookupPattern | def lookupPattern(self, name, layer):
""" See if there is a name/layer pattern combo, else return the name pattern. """
if (name, layer) in self.patterns:
return self.patterns[(name, layer)]
else:
return self.patterns[name] | python | def lookupPattern(self, name, layer):
""" See if there is a name/layer pattern combo, else return the name pattern. """
if (name, layer) in self.patterns:
return self.patterns[(name, layer)]
else:
return self.patterns[name] | [
"def",
"lookupPattern",
"(",
"self",
",",
"name",
",",
"layer",
")",
":",
"if",
"(",
"name",
",",
"layer",
")",
"in",
"self",
".",
"patterns",
":",
"return",
"self",
".",
"patterns",
"[",
"(",
"name",
",",
"layer",
")",
"]",
"else",
":",
"return",
... | See if there is a name/layer pattern combo, else return the name pattern. | [
"See",
"if",
"there",
"is",
"a",
"name",
"/",
"layer",
"pattern",
"combo",
"else",
"return",
"the",
"name",
"pattern",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3103-L3108 |
Calysto/calysto | calysto/ai/conx.py | Network.replacePatterns | def replacePatterns(self, vector, layer = None):
"""
Replaces patterned inputs or targets with activation vectors.
"""
if not self.patterned: return vector
if type(vector) == str:
return self.replacePatterns(self.lookupPattern(vector, layer), layer)
elif type(... | python | def replacePatterns(self, vector, layer = None):
"""
Replaces patterned inputs or targets with activation vectors.
"""
if not self.patterned: return vector
if type(vector) == str:
return self.replacePatterns(self.lookupPattern(vector, layer), layer)
elif type(... | [
"def",
"replacePatterns",
"(",
"self",
",",
"vector",
",",
"layer",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"patterned",
":",
"return",
"vector",
"if",
"type",
"(",
"vector",
")",
"==",
"str",
":",
"return",
"self",
".",
"replacePatterns",
"("... | Replaces patterned inputs or targets with activation vectors. | [
"Replaces",
"patterned",
"inputs",
"or",
"targets",
"with",
"activation",
"vectors",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3109-L3129 |
Calysto/calysto | calysto/ai/conx.py | Network.patternVector | def patternVector(self, vector):
"""
Replaces vector with patterns. Used for loading inputs or
targets from a file and still preserving patterns.
"""
if not self.patterned: return vector
if type(vector) == int:
if self.getWord(vector) != '':
re... | python | def patternVector(self, vector):
"""
Replaces vector with patterns. Used for loading inputs or
targets from a file and still preserving patterns.
"""
if not self.patterned: return vector
if type(vector) == int:
if self.getWord(vector) != '':
re... | [
"def",
"patternVector",
"(",
"self",
",",
"vector",
")",
":",
"if",
"not",
"self",
".",
"patterned",
":",
"return",
"vector",
"if",
"type",
"(",
"vector",
")",
"==",
"int",
":",
"if",
"self",
".",
"getWord",
"(",
"vector",
")",
"!=",
"''",
":",
"re... | Replaces vector with patterns. Used for loading inputs or
targets from a file and still preserving patterns. | [
"Replaces",
"vector",
"with",
"patterns",
".",
"Used",
"for",
"loading",
"inputs",
"or",
"targets",
"from",
"a",
"file",
"and",
"still",
"preserving",
"patterns",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3130-L3160 |
Calysto/calysto | calysto/ai/conx.py | Network.getPattern | def getPattern(self, word):
"""
Returns the pattern with key word.
Example: net.getPattern("tom") => [0, 0, 0, 1]
"""
if word in self.patterns:
return self.patterns[word]
else:
raise ValueError('Unknown pattern in getPattern().', word) | python | def getPattern(self, word):
"""
Returns the pattern with key word.
Example: net.getPattern("tom") => [0, 0, 0, 1]
"""
if word in self.patterns:
return self.patterns[word]
else:
raise ValueError('Unknown pattern in getPattern().', word) | [
"def",
"getPattern",
"(",
"self",
",",
"word",
")",
":",
"if",
"word",
"in",
"self",
".",
"patterns",
":",
"return",
"self",
".",
"patterns",
"[",
"word",
"]",
"else",
":",
"raise",
"ValueError",
"(",
"'Unknown pattern in getPattern().'",
",",
"word",
")"
... | Returns the pattern with key word.
Example: net.getPattern("tom") => [0, 0, 0, 1] | [
"Returns",
"the",
"pattern",
"with",
"key",
"word",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3172-L3182 |
Calysto/calysto | calysto/ai/conx.py | Network.getWord | def getWord(self, pattern, returnDiff = 0):
"""
Returns the word associated with pattern.
Example: net.getWord([0, 0, 0, 1]) => "tom"
This method now returns the closest pattern based on distance.
"""
minDist = 10000
closest = None
for w in self.patterns... | python | def getWord(self, pattern, returnDiff = 0):
"""
Returns the word associated with pattern.
Example: net.getWord([0, 0, 0, 1]) => "tom"
This method now returns the closest pattern based on distance.
"""
minDist = 10000
closest = None
for w in self.patterns... | [
"def",
"getWord",
"(",
"self",
",",
"pattern",
",",
"returnDiff",
"=",
"0",
")",
":",
"minDist",
"=",
"10000",
"closest",
"=",
"None",
"for",
"w",
"in",
"self",
".",
"patterns",
":",
"# There may be some patterns that are scalars; we don't search",
"# those in thi... | Returns the word associated with pattern.
Example: net.getWord([0, 0, 0, 1]) => "tom"
This method now returns the closest pattern based on distance. | [
"Returns",
"the",
"word",
"associated",
"with",
"pattern",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3183-L3210 |
Calysto/calysto | calysto/ai/conx.py | Network.addPattern | def addPattern(self, word, vector):
"""
Adds a pattern with key word.
Example: net.addPattern("tom", [0, 0, 0, 1])
"""
if word in self.patterns:
raise NetworkError('Pattern key already in use. Call delPattern to free key.', word)
else:
se... | python | def addPattern(self, word, vector):
"""
Adds a pattern with key word.
Example: net.addPattern("tom", [0, 0, 0, 1])
"""
if word in self.patterns:
raise NetworkError('Pattern key already in use. Call delPattern to free key.', word)
else:
se... | [
"def",
"addPattern",
"(",
"self",
",",
"word",
",",
"vector",
")",
":",
"if",
"word",
"in",
"self",
".",
"patterns",
":",
"raise",
"NetworkError",
"(",
"'Pattern key already in use. Call delPattern to free key.'",
",",
"word",
")",
"else",
":",
"self",
".",
"p... | Adds a pattern with key word.
Example: net.addPattern("tom", [0, 0, 0, 1]) | [
"Adds",
"a",
"pattern",
"with",
"key",
"word",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3221-L3231 |
Calysto/calysto | calysto/ai/conx.py | Network.compare | def compare(self, v1, v2):
"""
Compares two values. Returns 1 if all values are withing
self.tolerance of each other.
"""
try:
if len(v1) != len(v2): return 0
for x, y in zip(v1, v2):
if abs( x - y ) > self.tolerance:
re... | python | def compare(self, v1, v2):
"""
Compares two values. Returns 1 if all values are withing
self.tolerance of each other.
"""
try:
if len(v1) != len(v2): return 0
for x, y in zip(v1, v2):
if abs( x - y ) > self.tolerance:
re... | [
"def",
"compare",
"(",
"self",
",",
"v1",
",",
"v2",
")",
":",
"try",
":",
"if",
"len",
"(",
"v1",
")",
"!=",
"len",
"(",
"v2",
")",
":",
"return",
"0",
"for",
"x",
",",
"y",
"in",
"zip",
"(",
"v1",
",",
"v2",
")",
":",
"if",
"abs",
"(",
... | Compares two values. Returns 1 if all values are withing
self.tolerance of each other. | [
"Compares",
"two",
"values",
".",
"Returns",
"1",
"if",
"all",
"values",
"are",
"withing",
"self",
".",
"tolerance",
"of",
"each",
"other",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3241-L3260 |
Calysto/calysto | calysto/ai/conx.py | Network.shareWeights | def shareWeights(self, network, listOfLayerNamePairs = None):
"""
Share weights with another network. Connection
is broken after a randomize or change of size. Layers must have the same
names and sizes for shared connections in both networks.
Example: net.shareWeights(otherNet, ... | python | def shareWeights(self, network, listOfLayerNamePairs = None):
"""
Share weights with another network. Connection
is broken after a randomize or change of size. Layers must have the same
names and sizes for shared connections in both networks.
Example: net.shareWeights(otherNet, ... | [
"def",
"shareWeights",
"(",
"self",
",",
"network",
",",
"listOfLayerNamePairs",
"=",
"None",
")",
":",
"if",
"listOfLayerNamePairs",
"==",
"None",
":",
"listOfLayerNamePairs",
"=",
"[",
"]",
"for",
"c",
"in",
"self",
".",
"connections",
":",
"listOfLayerNameP... | Share weights with another network. Connection
is broken after a randomize or change of size. Layers must have the same
names and sizes for shared connections in both networks.
Example: net.shareWeights(otherNet, [["hidden", "output"]])
This example will take the weights between the hi... | [
"Share",
"weights",
"with",
"another",
"network",
".",
"Connection",
"is",
"broken",
"after",
"a",
"randomize",
"or",
"change",
"of",
"size",
".",
"Layers",
"must",
"have",
"the",
"same",
"names",
"and",
"sizes",
"for",
"shared",
"connections",
"in",
"both",... | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L3261-L3312 |
Calysto/calysto | calysto/ai/conx.py | BackpropNetwork.propagate | def propagate(self, *arg, **kw):
""" Propagates activation through the network."""
output = Network.propagate(self, *arg, **kw)
if self.interactive:
self.updateGraphics()
# IMPORTANT: convert results from numpy.floats to conventional floats
if type(output) == dict:
... | python | def propagate(self, *arg, **kw):
""" Propagates activation through the network."""
output = Network.propagate(self, *arg, **kw)
if self.interactive:
self.updateGraphics()
# IMPORTANT: convert results from numpy.floats to conventional floats
if type(output) == dict:
... | [
"def",
"propagate",
"(",
"self",
",",
"*",
"arg",
",",
"*",
"*",
"kw",
")",
":",
"output",
"=",
"Network",
".",
"propagate",
"(",
"self",
",",
"*",
"arg",
",",
"*",
"*",
"kw",
")",
"if",
"self",
".",
"interactive",
":",
"self",
".",
"updateGraphi... | Propagates activation through the network. | [
"Propagates",
"activation",
"through",
"the",
"network",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L4286-L4297 |
Calysto/calysto | calysto/ai/conx.py | BackpropNetwork.loadWeightsFromFile | def loadWeightsFromFile(self, filename, mode='pickle'):
"""
Deprecated. Use loadWeights instead.
"""
Network.loadWeights(self, filename, mode)
self.updateGraphics() | python | def loadWeightsFromFile(self, filename, mode='pickle'):
"""
Deprecated. Use loadWeights instead.
"""
Network.loadWeights(self, filename, mode)
self.updateGraphics() | [
"def",
"loadWeightsFromFile",
"(",
"self",
",",
"filename",
",",
"mode",
"=",
"'pickle'",
")",
":",
"Network",
".",
"loadWeights",
"(",
"self",
",",
"filename",
",",
"mode",
")",
"self",
".",
"updateGraphics",
"(",
")"
] | Deprecated. Use loadWeights instead. | [
"Deprecated",
".",
"Use",
"loadWeights",
"instead",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L4304-L4309 |
Calysto/calysto | calysto/ai/conx.py | BackpropNetwork.display | def display(self):
"""Displays the network to the screen."""
size = list(range(len(self.layers)))
size.reverse()
for i in size:
layer = self.layers[i]
if layer.active:
print('%s layer (size %d)' % (layer.name, layer.size))
tlabel, o... | python | def display(self):
"""Displays the network to the screen."""
size = list(range(len(self.layers)))
size.reverse()
for i in size:
layer = self.layers[i]
if layer.active:
print('%s layer (size %d)' % (layer.name, layer.size))
tlabel, o... | [
"def",
"display",
"(",
"self",
")",
":",
"size",
"=",
"list",
"(",
"range",
"(",
"len",
"(",
"self",
".",
"layers",
")",
")",
")",
"size",
".",
"reverse",
"(",
")",
"for",
"i",
"in",
"size",
":",
"layer",
"=",
"self",
".",
"layers",
"[",
"i",
... | Displays the network to the screen. | [
"Displays",
"the",
"network",
"to",
"the",
"screen",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L4443-L4484 |
Calysto/calysto | calysto/ai/conx.py | SRN.setSequenceType | def setSequenceType(self, value):
"""
You must set this!
"""
if value == "ordered-continuous":
self.orderedInputs = 1
self.initContext = 0
elif value == "random-segmented":
self.orderedInputs = 0
self.initCon... | python | def setSequenceType(self, value):
"""
You must set this!
"""
if value == "ordered-continuous":
self.orderedInputs = 1
self.initContext = 0
elif value == "random-segmented":
self.orderedInputs = 0
self.initCon... | [
"def",
"setSequenceType",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"==",
"\"ordered-continuous\"",
":",
"self",
".",
"orderedInputs",
"=",
"1",
"self",
".",
"initContext",
"=",
"0",
"elif",
"value",
"==",
"\"random-segmented\"",
":",
"self",
".",
... | You must set this! | [
"You",
"must",
"set",
"this!"
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L4584-L4602 |
Calysto/calysto | calysto/ai/conx.py | SRN.addLayers | def addLayers(self, *arg, **kw):
"""
Creates an N layer network with 'input', 'hidden1', 'hidden2',...
and 'output' layers. Keyword type indicates "parallel" or
"serial". If only one hidden layer, it is called "hidden".
"""
netType = "serial"
if "type" in kw:
... | python | def addLayers(self, *arg, **kw):
"""
Creates an N layer network with 'input', 'hidden1', 'hidden2',...
and 'output' layers. Keyword type indicates "parallel" or
"serial". If only one hidden layer, it is called "hidden".
"""
netType = "serial"
if "type" in kw:
... | [
"def",
"addLayers",
"(",
"self",
",",
"*",
"arg",
",",
"*",
"*",
"kw",
")",
":",
"netType",
"=",
"\"serial\"",
"if",
"\"type\"",
"in",
"kw",
":",
"netType",
"=",
"kw",
"[",
"\"type\"",
"]",
"self",
".",
"addLayer",
"(",
"'input'",
",",
"arg",
"[",
... | Creates an N layer network with 'input', 'hidden1', 'hidden2',...
and 'output' layers. Keyword type indicates "parallel" or
"serial". If only one hidden layer, it is called "hidden". | [
"Creates",
"an",
"N",
"layer",
"network",
"with",
"input",
"hidden1",
"hidden2",
"...",
"and",
"output",
"layers",
".",
"Keyword",
"type",
"indicates",
"parallel",
"or",
"serial",
".",
"If",
"only",
"one",
"hidden",
"layer",
"it",
"is",
"called",
"hidden",
... | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L4621-L4666 |
Calysto/calysto | calysto/ai/conx.py | SRN.addThreeLayers | def addThreeLayers(self, inc, hidc, outc):
"""
Creates a three level network with a context layer.
"""
self.addLayer('input', inc)
self.addContextLayer('context', hidc, 'hidden')
self.addLayer('hidden', hidc)
self.addLayer('output', outc)
self.connect('inp... | python | def addThreeLayers(self, inc, hidc, outc):
"""
Creates a three level network with a context layer.
"""
self.addLayer('input', inc)
self.addContextLayer('context', hidc, 'hidden')
self.addLayer('hidden', hidc)
self.addLayer('output', outc)
self.connect('inp... | [
"def",
"addThreeLayers",
"(",
"self",
",",
"inc",
",",
"hidc",
",",
"outc",
")",
":",
"self",
".",
"addLayer",
"(",
"'input'",
",",
"inc",
")",
"self",
".",
"addContextLayer",
"(",
"'context'",
",",
"hidc",
",",
"'hidden'",
")",
"self",
".",
"addLayer"... | Creates a three level network with a context layer. | [
"Creates",
"a",
"three",
"level",
"network",
"with",
"a",
"context",
"layer",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L4667-L4677 |
Calysto/calysto | calysto/ai/conx.py | SRN.addSRNLayers | def addSRNLayers(self, inc, hidc, outc):
"""
Wraps SRN.addThreeLayers() for compatibility.
"""
self.addThreeLayers(inc, hidc, outc) | python | def addSRNLayers(self, inc, hidc, outc):
"""
Wraps SRN.addThreeLayers() for compatibility.
"""
self.addThreeLayers(inc, hidc, outc) | [
"def",
"addSRNLayers",
"(",
"self",
",",
"inc",
",",
"hidc",
",",
"outc",
")",
":",
"self",
".",
"addThreeLayers",
"(",
"inc",
",",
"hidc",
",",
"outc",
")"
] | Wraps SRN.addThreeLayers() for compatibility. | [
"Wraps",
"SRN",
".",
"addThreeLayers",
"()",
"for",
"compatibility",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L4678-L4682 |
Calysto/calysto | calysto/ai/conx.py | SRN.addContext | def addContext(self, layer, hiddenLayerName = 'hidden', verbosity = 0):
"""
Adds a context layer. Necessary to keep self.contextLayers dictionary up to date.
"""
# better not add context layer first if using sweep() without mapInput
SRN.add(self, layer, verbosity)
if hid... | python | def addContext(self, layer, hiddenLayerName = 'hidden', verbosity = 0):
"""
Adds a context layer. Necessary to keep self.contextLayers dictionary up to date.
"""
# better not add context layer first if using sweep() without mapInput
SRN.add(self, layer, verbosity)
if hid... | [
"def",
"addContext",
"(",
"self",
",",
"layer",
",",
"hiddenLayerName",
"=",
"'hidden'",
",",
"verbosity",
"=",
"0",
")",
":",
"# better not add context layer first if using sweep() without mapInput",
"SRN",
".",
"add",
"(",
"self",
",",
"layer",
",",
"verbosity",
... | Adds a context layer. Necessary to keep self.contextLayers dictionary up to date. | [
"Adds",
"a",
"context",
"layer",
".",
"Necessary",
"to",
"keep",
"self",
".",
"contextLayers",
"dictionary",
"up",
"to",
"date",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L4686-L4697 |
Calysto/calysto | calysto/ai/conx.py | SRN.copyHiddenToContext | def copyHiddenToContext(self):
"""
Uses key to identify the hidden layer associated with each
layer in the self.contextLayers dictionary.
"""
for item in list(self.contextLayers.items()):
if self.verbosity > 2: print('Hidden layer: ', self.getLayer(item[0]).activatio... | python | def copyHiddenToContext(self):
"""
Uses key to identify the hidden layer associated with each
layer in the self.contextLayers dictionary.
"""
for item in list(self.contextLayers.items()):
if self.verbosity > 2: print('Hidden layer: ', self.getLayer(item[0]).activatio... | [
"def",
"copyHiddenToContext",
"(",
"self",
")",
":",
"for",
"item",
"in",
"list",
"(",
"self",
".",
"contextLayers",
".",
"items",
"(",
")",
")",
":",
"if",
"self",
".",
"verbosity",
">",
"2",
":",
"print",
"(",
"'Hidden layer: '",
",",
"self",
".",
... | Uses key to identify the hidden layer associated with each
layer in the self.contextLayers dictionary. | [
"Uses",
"key",
"to",
"identify",
"the",
"hidden",
"layer",
"associated",
"with",
"each",
"layer",
"in",
"the",
"self",
".",
"contextLayers",
"dictionary",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L4700-L4709 |
Calysto/calysto | calysto/ai/conx.py | SRN.setContext | def setContext(self, value = .5):
"""
Clears the context layer by setting context layer to (default) value 0.5.
"""
for context in list(self.contextLayers.values()):
context.resetFlags() # hidden activations have already been copied in
context.setActivations(valu... | python | def setContext(self, value = .5):
"""
Clears the context layer by setting context layer to (default) value 0.5.
"""
for context in list(self.contextLayers.values()):
context.resetFlags() # hidden activations have already been copied in
context.setActivations(valu... | [
"def",
"setContext",
"(",
"self",
",",
"value",
"=",
".5",
")",
":",
"for",
"context",
"in",
"list",
"(",
"self",
".",
"contextLayers",
".",
"values",
"(",
")",
")",
":",
"context",
".",
"resetFlags",
"(",
")",
"# hidden activations have already been copied ... | Clears the context layer by setting context layer to (default) value 0.5. | [
"Clears",
"the",
"context",
"layer",
"by",
"setting",
"context",
"layer",
"to",
"(",
"default",
")",
"value",
"0",
".",
"5",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L4710-L4716 |
Calysto/calysto | calysto/ai/conx.py | SRN.step | def step(self, **args):
"""
SRN.step()
Extends network step method by automatically copying hidden
layer activations to the context layer.
"""
if self.sequenceType == None:
raise AttributeError("""sequenceType not set! Use SRN.setSequenceType() """)
# ... | python | def step(self, **args):
"""
SRN.step()
Extends network step method by automatically copying hidden
layer activations to the context layer.
"""
if self.sequenceType == None:
raise AttributeError("""sequenceType not set! Use SRN.setSequenceType() """)
# ... | [
"def",
"step",
"(",
"self",
",",
"*",
"*",
"args",
")",
":",
"if",
"self",
".",
"sequenceType",
"==",
"None",
":",
"raise",
"AttributeError",
"(",
"\"\"\"sequenceType not set! Use SRN.setSequenceType() \"\"\"",
")",
"# take care of any params other than layer names:",
"... | SRN.step()
Extends network step method by automatically copying hidden
layer activations to the context layer. | [
"SRN",
".",
"step",
"()",
"Extends",
"network",
"step",
"method",
"by",
"automatically",
"copying",
"hidden",
"layer",
"activations",
"to",
"the",
"context",
"layer",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L4722-L4828 |
Calysto/calysto | calysto/ai/conx.py | SRN.showPerformance | def showPerformance(self):
"""
SRN.showPerformance()
Clears the context layer(s) and then repeatedly cycles through
training patterns until the user decides to quit.
"""
if len(self.inputs) == 0:
print('no patterns to test')
return
self.set... | python | def showPerformance(self):
"""
SRN.showPerformance()
Clears the context layer(s) and then repeatedly cycles through
training patterns until the user decides to quit.
"""
if len(self.inputs) == 0:
print('no patterns to test')
return
self.set... | [
"def",
"showPerformance",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"inputs",
")",
"==",
"0",
":",
"print",
"(",
"'no patterns to test'",
")",
"return",
"self",
".",
"setContext",
"(",
")",
"while",
"True",
":",
"BackpropNetwork",
".",
"showP... | SRN.showPerformance()
Clears the context layer(s) and then repeatedly cycles through
training patterns until the user decides to quit. | [
"SRN",
".",
"showPerformance",
"()",
"Clears",
"the",
"context",
"layer",
"(",
"s",
")",
"and",
"then",
"repeatedly",
"cycles",
"through",
"training",
"patterns",
"until",
"the",
"user",
"decides",
"to",
"quit",
"."
] | train | https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L4851-L4864 |
marshallward/f90nml | f90nml/tokenizer.py | Tokenizer.parse | def parse(self, line):
"""Tokenize a line of Fortran source."""
tokens = []
self.idx = -1 # Bogus value to ensure idx = 0 after first iteration
self.characters = iter(line)
self.update_chars()
while self.char != '\n':
# Update namelist group status
... | python | def parse(self, line):
"""Tokenize a line of Fortran source."""
tokens = []
self.idx = -1 # Bogus value to ensure idx = 0 after first iteration
self.characters = iter(line)
self.update_chars()
while self.char != '\n':
# Update namelist group status
... | [
"def",
"parse",
"(",
"self",
",",
"line",
")",
":",
"tokens",
"=",
"[",
"]",
"self",
".",
"idx",
"=",
"-",
"1",
"# Bogus value to ensure idx = 0 after first iteration",
"self",
".",
"characters",
"=",
"iter",
"(",
"line",
")",
"self",
".",
"update_chars",
... | Tokenize a line of Fortran source. | [
"Tokenize",
"a",
"line",
"of",
"Fortran",
"source",
"."
] | train | https://github.com/marshallward/f90nml/blob/4932cabc5221afc844ee6a5b4a05ceb8bd4a2711/f90nml/tokenizer.py#L32-L105 |
marshallward/f90nml | f90nml/tokenizer.py | Tokenizer.parse_name | def parse_name(self, line):
"""Tokenize a Fortran name, such as a variable or subroutine."""
end = self.idx
for char in line[self.idx:]:
if not char.isalnum() and char not in '\'"_':
break
end += 1
word = line[self.idx:end]
self.idx = end... | python | def parse_name(self, line):
"""Tokenize a Fortran name, such as a variable or subroutine."""
end = self.idx
for char in line[self.idx:]:
if not char.isalnum() and char not in '\'"_':
break
end += 1
word = line[self.idx:end]
self.idx = end... | [
"def",
"parse_name",
"(",
"self",
",",
"line",
")",
":",
"end",
"=",
"self",
".",
"idx",
"for",
"char",
"in",
"line",
"[",
"self",
".",
"idx",
":",
"]",
":",
"if",
"not",
"char",
".",
"isalnum",
"(",
")",
"and",
"char",
"not",
"in",
"'\\'\"_'",
... | Tokenize a Fortran name, such as a variable or subroutine. | [
"Tokenize",
"a",
"Fortran",
"name",
"such",
"as",
"a",
"variable",
"or",
"subroutine",
"."
] | train | https://github.com/marshallward/f90nml/blob/4932cabc5221afc844ee6a5b4a05ceb8bd4a2711/f90nml/tokenizer.py#L107-L123 |
marshallward/f90nml | f90nml/tokenizer.py | Tokenizer.parse_string | def parse_string(self):
"""Tokenize a Fortran string."""
word = ''
if self.prior_delim:
delim = self.prior_delim
self.prior_delim = None
else:
delim = self.char
word += self.char
self.update_chars()
while True:
... | python | def parse_string(self):
"""Tokenize a Fortran string."""
word = ''
if self.prior_delim:
delim = self.prior_delim
self.prior_delim = None
else:
delim = self.char
word += self.char
self.update_chars()
while True:
... | [
"def",
"parse_string",
"(",
"self",
")",
":",
"word",
"=",
"''",
"if",
"self",
".",
"prior_delim",
":",
"delim",
"=",
"self",
".",
"prior_delim",
"self",
".",
"prior_delim",
"=",
"None",
"else",
":",
"delim",
"=",
"self",
".",
"char",
"word",
"+=",
"... | Tokenize a Fortran string. | [
"Tokenize",
"a",
"Fortran",
"string",
"."
] | train | https://github.com/marshallward/f90nml/blob/4932cabc5221afc844ee6a5b4a05ceb8bd4a2711/f90nml/tokenizer.py#L125-L154 |
marshallward/f90nml | f90nml/tokenizer.py | Tokenizer.parse_numeric | def parse_numeric(self):
"""Tokenize a Fortran numerical value."""
word = ''
frac = False
if self.char == '-':
word += self.char
self.update_chars()
while self.char.isdigit() or (self.char == '.' and not frac):
# Only allow one decimal point
... | python | def parse_numeric(self):
"""Tokenize a Fortran numerical value."""
word = ''
frac = False
if self.char == '-':
word += self.char
self.update_chars()
while self.char.isdigit() or (self.char == '.' and not frac):
# Only allow one decimal point
... | [
"def",
"parse_numeric",
"(",
"self",
")",
":",
"word",
"=",
"''",
"frac",
"=",
"False",
"if",
"self",
".",
"char",
"==",
"'-'",
":",
"word",
"+=",
"self",
".",
"char",
"self",
".",
"update_chars",
"(",
")",
"while",
"self",
".",
"char",
".",
"isdig... | Tokenize a Fortran numerical value. | [
"Tokenize",
"a",
"Fortran",
"numerical",
"value",
"."
] | train | https://github.com/marshallward/f90nml/blob/4932cabc5221afc844ee6a5b4a05ceb8bd4a2711/f90nml/tokenizer.py#L156-L184 |
marshallward/f90nml | f90nml/tokenizer.py | Tokenizer.update_chars | def update_chars(self):
"""Update the current charters in the tokenizer."""
# NOTE: We spoof non-Unix files by returning '\n' on StopIteration
self.prior_char, self.char = self.char, next(self.characters, '\n')
self.idx += 1 | python | def update_chars(self):
"""Update the current charters in the tokenizer."""
# NOTE: We spoof non-Unix files by returning '\n' on StopIteration
self.prior_char, self.char = self.char, next(self.characters, '\n')
self.idx += 1 | [
"def",
"update_chars",
"(",
"self",
")",
":",
"# NOTE: We spoof non-Unix files by returning '\\n' on StopIteration",
"self",
".",
"prior_char",
",",
"self",
".",
"char",
"=",
"self",
".",
"char",
",",
"next",
"(",
"self",
".",
"characters",
",",
"'\\n'",
")",
"s... | Update the current charters in the tokenizer. | [
"Update",
"the",
"current",
"charters",
"in",
"the",
"tokenizer",
"."
] | train | https://github.com/marshallward/f90nml/blob/4932cabc5221afc844ee6a5b4a05ceb8bd4a2711/f90nml/tokenizer.py#L186-L190 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.