本文整理汇总了Python中Node.Node.get_map方法的典型用法代码示例。如果您正苦于以下问题:Python Node.get_map方法的具体用法?Python Node.get_map怎么用?Python Node.get_map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node.Node
的用法示例。
在下文中一共展示了Node.get_map方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calculate_neighborhood
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import get_map [as 别名]
def calculate_neighborhood(self, _, cell_string):
## Load grid weights
grid = Node.get_map(self.options.map)
## Extract weight vectors from passed cell
cell = cell_string.split(",")
x_coord = int(cell[0])
y_coord = int(cell[1])
weights = [float(x) for x in cell[2:]]
## Construct node object
node = Node(x_coord, y_coord, len(weights), weights)
## Calculate neighbors' distance
for i in range(max(0, x_coord - 1), min(len(self.grid), x_coord + 2)):
for j in range(max(0, y_coord - 1), min(len(self.grid[0]), y_coord + 2)):
distance = self.grid[i][j].calculate_distance(weights)
yield((x_coord, y_coord), distance)
示例2: calculate_neighborhood
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import get_map [as 别名]
def calculate_neighborhood(self, _, input_vector):
## Load grid weights
grid = Node.get_map(self.options.map)
## Extract weight vectors from passed fields
input_vector = [float(x) for x in input_vector.split(",")][1:]
## Find BMU
x, y = Node.compute_winning_vector(self.grid, input_vector)
## Calculate Gausian neighborhood function for all grid nodes
for i, row in enumerate(grid):
for j, node in enumerate(row):
coor_distance = (i - int(x)) ** 2 + (j - int(y)) ** 2
denominator = math.exp(-coor_distance / self.options.theta ** 2)
numerator = [denominator * x for x in input_vector]
yield((i, j), (numerator, denominator))
示例3: load_weights
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import get_map [as 别名]
def load_weights(self):
## Load grid weights from file
self.grid = Node.get_map(self.options.map)