本文整理汇总了Python中cluster.Cluster.add_neuron方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.add_neuron方法的具体用法?Python Cluster.add_neuron怎么用?Python Cluster.add_neuron使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cluster.Cluster
的用法示例。
在下文中一共展示了Cluster.add_neuron方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import add_neuron [as 别名]
def __init__(self, *args, **kwargs):
braindata = kwargs.get("braindata", None)
if braindata is None:
print("Intializing brain...")
print("Neuron count: {0}".format(args[0]))
print("Clusters: {0}".format(args[1]))
self.num_neurons = args[0]
self.num_clusters = args[1]
self.max_value = args[2]
for n in xrange(self.num_clusters):
x = randrange(0, self.max_value)
y = randrange(0, self.max_value)
z = randrange(0, self.max_value)
self.clusters.insert(len(self.clusters), Cluster(x, y, z, n))
else:
nodesfile = braindata + "/neurons.csv"
clustersfile = braindata + "/clusters.csv"
edgesfile = braindata + "/edges.csv"
with open(nodesfile, "r") as nfile:
self.num_neurons = nfile.readline().strip() # read first line count in
for line in nfile:
line = line.strip()
ndata = line.split(", ")
self.neurons.append(Neuron(int(ndata[1]), int(ndata[2]), int(ndata[3]), int(ndata[0]), int(ndata[4])))
with open(clustersfile, "r") as cfile:
self.num_clusters = cfile.readline().strip() # read first line count in
for line in cfile:
line = line.strip()
cdata = line.split(", ")
temp_cluster = Cluster(float(cdata[1]), float(cdata[2]), float(cdata[3]), int(cdata[0]))
for neuron in self.neurons:
# print(neuron.info())
if int(cdata[0]) == int(neuron.get_cluster()):
temp_cluster.add_neuron(neuron)
self.clusters.insert(len(self.clusters), temp_cluster)
with open(edgesfile, "r") as efile:
efile.readline().strip() # dump edges count
for line in efile:
line = line.strip()
edata = line.split(", ")
self.edges.append([int(edata[0]), int(edata[1])])