【发布时间】:2018-04-16 03:17:28
【问题描述】:
我正在编写一个基本的神经网络,并希望将其绘制成一张图片。为此,我创建了我需要的所有节点和边。
for l, j in zip(self.layers, range(len(self.layers))):
for n, i in zip(l.neurons, range(len(l.neurons))):
fixed_positions[n.identifier] = (j, i)
for l in self.layers:
for n in l.neurons:
for c, w in zip(n.inconnections, n.inconnectionweights):
g.add_edge(n.identifier, c.identifier)
fixed_nodes = fixed_positions.keys()
pos = nx.spring_layout(g, pos=fixed_positions, fixed=fixed_nodes)
蓝色点(想象它们在所有边缘)是我想在边缘添加标签的地方,但我不知道该怎么做。它应该适用于任何合理的净尺寸,即它也应该适用于相应层中的 4、3 和 2 个神经元。
【问题讨论】:
-
感谢您的回答,不幸的是不是真的,因为我需要修复边缘开始处的标签,否则交叉部分中有一堆乱七八糟的数字,没有人可以阅读它。
-
networkx.github.io/documentation/latest/reference/generated/… 有一个
label_pos参数,用于确定标签沿边缘的距离(作为 0 和 1 之间的浮点数,0 位于起始节点的末尾,1 位于在另一端)- 这有帮助吗? -
我还没有尝试过,但它看起来像我正在寻找的东西,谢谢!
-
@bouteillebleu 这正是我想要的,非常感谢