代码1(画神经网络连接图)
from math import cos, sin, atan
import matplotlib.pyplot as plt
# 注意这里并没有用到这个networkx这个库,完全是根据matploblib这个库来画的。
class Neuron():
def __init__(self, x, y,radius,name=None):
self.x = x
self.y = y
self.radius = radius
self.name = name
def draw(self):
circle = plt.Circle((self.x, self.y), radius=self.radius, fill=False)
plt.gca().add_patch(circle)
if(self.name is not None):
plt.text(self.x,self.y,self.name)
#注意这个写法,现在整个图是水平的,不再是竖直的
def plotConnection(neuron1,neuron2):
neuron_radius= neuron1.radius
angle = atan((neuron2.y - neuron1.y)/float(neuron2.x - neuron1.x))
x_adjustment = neuron_radius * cos(angle)
y_adjustment = neuron_radius * sin(angle)
line = plt.Line2D((neuron1.x + x_adjustment, neuron2.x - x_adjustment), (neuron1.y + y_adjustment, neuron2.y - y_adjustment),color="gray")
plt.gca().add_line(line)
class Connection():
def __init__(self,neuron1,neuron2):
self.n1 = neuron1
self.n2 = neuron2
pass
#
radius =0.05
n1 = Neuron(1,1.1,radius,name="n1")
n1.draw()
n2 = Neuron(1,1.3,radius,name="n2")
n2.draw()
n3 = Neuron(1,1.5,radius,name="n3")
n3.draw()
n4 = Neuron(1,1.7,radius)
n4.draw()
n5 = Neuron(1,1.9,radius)
n5.draw()
n6 = Neuron(2,1.0,radius)
n6.draw()
n7 = Neuron(2,1.2,radius,name="n7")
n7.draw()
n8 = Neuron(2,1.4,radius)
n8.draw()
n9 = Neuron(2,1.6,radius,name="n9")
n9.draw()
n10 = Neuron(2,1.8,radius)
n10.draw()
n11 = Neuron(2,2.0,radius)
n11.draw()
plotConnection(n2,n7)
plotConnection(n1,n9)
plotConnection(n3,n8)
plt.axis("scaled")
plt.show()
## 现在这个地方有一个问题,就是这个图形应该是什么样子的
结果如下
代码2(画神经网络层连接)
from math import cos, sin, atan
import matplotlib.pyplot as plt
from itertools import product
# 注意这里并没有用到这个networkx这个库,完全是根据matploblib这个库来画的。
class Neuron():
def __init__(self, x, y,radius,name=None):
self.x = x
self.y = y
self.radius = radius
self.name = name
def draw(self):
circle = plt.Circle((self.x, self.y), radius=self.radius, fill=False)
plt.gca().add_patch(circle)
if(self.name is not None):
plt.text(self.x,self.y,self.name)
# 我是水平方向构造这个Layer类
class NeuronLayer():
def __init__(self,positionX,initY,numNeurons,numNeuronsWidestLayer,vertical_distance_between_neurons,radius):
# positionX:水平位置
# numNeurons:神经元个数
# numNeuronsWidestLayer: 为了居中,我需要知道最大的宽度, 并且计算出每个神经元的纵轴位置
# vertical_distance_between_neurons: 相邻神经元的margin
# radius: 每个神经元的半径
self.positionX = positionX
self.initY = initY
self.numNeurons = numNeurons
positionY = initY + vertical_distance_between_neurons * (numNeuronsWidestLayer - numNeurons) / 2
self.NeuronList=[]
for i in range(numNeurons):
neu = Neuron(self.positionX,positionY,radius)
neu.draw()
self.NeuronList.append(neu)
positionY = positionY + vertical_distance_between_neurons
#注意这个写法,现在整个图是水平的,不再是竖直的
def TwoNeuronsConnection(neuron1,neuron2):
neuron_radius= neuron1.radius
angle = atan((neuron2.y - neuron1.y)/float(neuron2.x - neuron1.x))
x_adjustment = neuron_radius * cos(angle)
y_adjustment = neuron_radius * sin(angle)
line = plt.Line2D((neuron1.x + x_adjustment, neuron2.x - x_adjustment), (neuron1.y + y_adjustment, neuron2.y - y_adjustment),color="gray",linewidth=0.2)
plt.gca().add_line(line)
def TwoLayersConnection(NeuronLayer1,NeuronLayer2):
Layer1 = NeuronLayer1.NeuronList
Layer2 = NeuronLayer2.NeuronList
for neuron1,neuron2 in product(Layer1,Layer2):
TwoNeuronsConnection(neuron1,neuron2)
##############################################
radius =0.05
Layer1 = NeuronLayer(positionX=1,initY= 0.0,numNeurons=4,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.2,radius=0.05)
Layer2= NeuronLayer(positionX=2,initY= 0.0,numNeurons=10,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.2,radius=0.05)
Layer3 = NeuronLayer(positionX=3,initY= 0.0,numNeurons=8,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.2,radius=0.05)
Layer4 = NeuronLayer(positionX=4,initY= 0.0,numNeurons=5,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.2,radius=0.05)
Layer5 = NeuronLayer(positionX=5,initY= 0.0,numNeurons=1,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.2,radius=0.05)
TwoLayersConnection(Layer1,Layer2)
TwoLayersConnection(Layer2,Layer3)
TwoLayersConnection(Layer3,Layer4)
TwoLayersConnection(Layer4,Layer5)
########################
plt.axis("scaled")
#plt.axis('off')
plt.show()
########################
## 现在这个地方有一个问题,就是这个图形应该是什么样子的
## 这个
结果如下
代码3(画两个子网络)
from math import cos, sin, atan
import matplotlib.pyplot as plt
from itertools import product
# 注意这里并没有用到这个networkx这个库,完全是根据matploblib这个库来画的。
class Neuron():
def __init__(self, x, y,radius,name=None):
self.x = x
self.y = y
self.radius = radius
self.name = name
def draw(self):
circle = plt.Circle((self.x, self.y), radius=self.radius, fill=False)
plt.gca().add_patch(circle)
if(self.name is not None):
plt.text(self.x,self.y,self.name)
# 我是水平方向构造这个Layer类
class NeuronLayer():
def __init__(self,positionX,initY,numNeurons,numNeuronsWidestLayer,vertical_distance_between_neurons,radius):
# positionX:水平位置
# numNeurons:神经元个数
# numNeuronsWidestLayer: 为了居中,我需要知道最大的宽度, 并且计算出每个神经元的纵轴位置
# vertical_distance_between_neurons: 相邻神经元的margin
# radius: 每个神经元的半径
self.positionX = positionX
self.initY = initY
self.numNeurons = numNeurons
positionY = initY + vertical_distance_between_neurons * (numNeuronsWidestLayer - numNeurons) / 2
self.NeuronList=[]
for i in range(numNeurons):
neu = Neuron(self.positionX,positionY,radius)
neu.draw()
self.NeuronList.append(neu)
positionY = positionY + vertical_distance_between_neurons
#注意这个写法,现在整个图是水平的,不再是竖直的
def TwoNeuronsConnection(neuron1,neuron2):
neuron_radius= neuron1.radius
angle = atan((neuron2.y - neuron1.y)/float(neuron2.x - neuron1.x))
x_adjustment = neuron_radius * cos(angle)
y_adjustment = neuron_radius * sin(angle)
line = plt.Line2D((neuron1.x + x_adjustment, neuron2.x - x_adjustment), (neuron1.y + y_adjustment, neuron2.y - y_adjustment),color="gray",linewidth=0.2)
plt.gca().add_line(line)
def TwoLayersConnection(NeuronLayer1,NeuronLayer2):
Layer1 = NeuronLayer1.NeuronList
Layer2 = NeuronLayer2.NeuronList
for neuron1,neuron2 in product(Layer1,Layer2):
TwoNeuronsConnection(neuron1,neuron2)
##############################################
radius =0.05
Layer11 = NeuronLayer(positionX=1,initY= 0.0,numNeurons=4,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.25,radius=0.05)
Layer12= NeuronLayer(positionX=1,initY= 1,numNeurons=4,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.25,radius=0.05)
Layer21 = NeuronLayer(positionX=2,initY= 0.0,numNeurons=10,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=0.05)
Layer22 = NeuronLayer(positionX=2,initY= 1.8,numNeurons=10,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=0.05)
Layer31 = NeuronLayer(positionX=3,initY= 0.0,numNeurons=8,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=0.05)
Layer32 = NeuronLayer(positionX=3,initY= 1.8,numNeurons=8,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=0.05)
Layer41 = NeuronLayer(positionX=4,initY= 0.0,numNeurons=5,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=0.05)
Layer42 = NeuronLayer(positionX=4,initY= 1.8,numNeurons=5,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=0.05)
Layer51 = NeuronLayer(positionX=5,initY= 0.0,numNeurons=1,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=0.05)
Layer52 = NeuronLayer(positionX=5,initY= 1.8,numNeurons=1,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=0.05)
TwoLayersConnection(Layer11,Layer21)
TwoLayersConnection(Layer11,Layer22)
TwoLayersConnection(Layer12,Layer21)
TwoLayersConnection(Layer12,Layer22)
TwoLayersConnection(Layer21,Layer31)
TwoLayersConnection(Layer22,Layer32)
TwoLayersConnection(Layer31,Layer41)
TwoLayersConnection(Layer32,Layer42)
TwoLayersConnection(Layer41,Layer51)
TwoLayersConnection(Layer42,Layer52)
########################
plt.axis("scaled")
#plt.axis('off')
plt.show()
########################
## 现在这个地方有一个问题,就是这个图形应该是什么样子的
## 这个
结果如下
添加变量
from math import cos, sin, atan
import matplotlib.pyplot as plt
from itertools import product
# mac显示中文##
plt.rcParams['font.sans-serif']=['Songti SC'] #用来正常显示中文标签
# 首先实现Neuron类
class Neuron():
def __init__(self, x, y,radius,name=None):
self.x = x
self.y = y
self.radius = radius
self.name = name
def draw(self):
circle = plt.Circle((self.x, self.y), radius=self.radius, fill=False)
plt.gca().add_patch(circle)
if(self.name is not None):
plt.text(self.x,self.y,self.name)
# 水平方向构造Layer类
class NeuronLayer():
def __init__(self,positionX,initY,numNeurons,numNeuronsWidestLayer,vertical_distance_between_neurons,radius):
# positionX:水平位置
# initY: 神经元的初始位置
# numNeurons:神经元个数
# numNeuronsWidestLayer: 为了居中,我需要知道最大的宽度, 并且计算出每个神经元的纵轴位置
# vertical_distance_between_neurons: 相邻神经元的margin
# radius: 每个神经元的半径
self.positionX = positionX
self.initY = initY
self.numNeurons = numNeurons
positionY = initY + vertical_distance_between_neurons * (numNeuronsWidestLayer - numNeurons) / 2
self.NeuronList=[]
for i in range(numNeurons):
neu = Neuron(self.positionX,positionY,radius)
neu.draw()
self.NeuronList.append(neu)
positionY = positionY + vertical_distance_between_neurons
class PlotNeuralConnection:
def __init__():
pass
# 连接两个神经元
def TwoNeuronsConnection(neuron1,neuron2):
neuron_radius= neuron1.radius
angle = atan((neuron2.y - neuron1.y)/float(neuron2.x - neuron1.x))
x_adjustment = neuron_radius * cos(angle)
y_adjustment = neuron_radius * sin(angle)
##################### 添加直线 ###########################
line = plt.Line2D((neuron1.x + x_adjustment, neuron2.x - x_adjustment), (neuron1.y + y_adjustment, neuron2.y - y_adjustment),color="gray",linewidth=0.2)
plt.gca().add_line(line)
#########################################################
##################### 添加箭头(不好看) ###########################
# startX,startY = neuron1.x + x_adjustment,neuron1.y + y_adjustment
# deltaX,deltaY = neuron2.x - x_adjustment - startX ,neuron2.y - y_adjustment - startY
# plt.gca().arrow(startX,startY,deltaX,deltaY, width=0.001, color="gray",
# head_width=0.01, head_length=0.05, overhang=1.0,length_includes_head=True)
#########################################################
# 连接相邻两层神经元
def TwoLayersConnection(NeuronLayer1,NeuronLayer2):
Layer1 = NeuronLayer1.NeuronList
Layer2 = NeuronLayer2.NeuronList
for neuron1,neuron2 in product(Layer1,Layer2):
TwoNeuronsConnection(neuron1,neuron2)
##############################################
radius =0.075
Layer11 = NeuronLayer(positionX=1,initY= 0.0,numNeurons=4,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.25,radius=radius)
Layer12= NeuronLayer(positionX=1,initY= 1,numNeurons=4,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.25,radius=radius)
Layer21 = NeuronLayer(positionX=2,initY= 0.0,numNeurons=10,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer22 = NeuronLayer(positionX=2,initY= 1.8,numNeurons=10,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer31 = NeuronLayer(positionX=3,initY= 0.0,numNeurons=8,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer32 = NeuronLayer(positionX=3,initY= 1.8,numNeurons=8,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer41 = NeuronLayer(positionX=4,initY= 0.0,numNeurons=5,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer42 = NeuronLayer(positionX=4,initY= 1.8,numNeurons=5,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer51 = NeuronLayer(positionX=5,initY= 0.0,numNeurons=1,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer52 = NeuronLayer(positionX=5,initY= 1.8,numNeurons=1,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
TwoLayersConnection(Layer11,Layer21)
TwoLayersConnection(Layer11,Layer22)
TwoLayersConnection(Layer12,Layer21)
TwoLayersConnection(Layer12,Layer22)
TwoLayersConnection(Layer21,Layer31)
TwoLayersConnection(Layer22,Layer32)
TwoLayersConnection(Layer31,Layer41)
TwoLayersConnection(Layer32,Layer42)
TwoLayersConnection(Layer41,Layer51)
TwoLayersConnection(Layer42,Layer52)
############################################################################################
############################## 添加变量名 ###########################
cnt = 1
for neu in Layer11.NeuronList:
plt.text(neu.x -0.5,neu.y-0.05,"变量{}".format(9-cnt))
cnt=cnt+1
cnt = 1
for neu in Layer12.NeuronList:
plt.text(neu.x -0.5,neu.y-0.05,"变量{}".format(5-cnt))
cnt=cnt+1
###################################################################
############################## 添加上箭头 ###########################
###################################################################
######################### 去除画图边框 ##############################
plt.axis("scaled")
plt.axis('off')
plt.show()
####################################################################
结果如下
文章来源:https://www.toymoban.com/news/detail-852125.html
初稿1
from math import cos, sin, atan
import matplotlib.pyplot as plt
from itertools import product
# mac显示中文##
plt.rcParams['font.sans-serif']=['Songti SC'] #用来正常显示中文标签
# 首先实现Neuron类
class Neuron():
def __init__(self, x, y,radius,name=None):
self.x = x
self.y = y
self.radius = radius
self.name = name
def draw(self):
circle = plt.Circle((self.x, self.y), radius=self.radius, fill=False)
plt.gca().add_patch(circle)
if(self.name is not None):
plt.text(self.x,self.y,self.name)
# 水平方向构造Layer类
class NeuronLayer():
def __init__(self,positionX,initY,numNeurons,numNeuronsWidestLayer,vertical_distance_between_neurons,radius):
# positionX:水平位置
# initY: 神经元的初始位置
# numNeurons:神经元个数
# numNeuronsWidestLayer: 为了居中,我需要知道最大的宽度, 并且计算出每个神经元的纵轴位置
# vertical_distance_between_neurons: 相邻神经元的margin
# radius: 每个神经元的半径
self.positionX = positionX
self.initY = initY
self.numNeurons = numNeurons
positionY = initY + vertical_distance_between_neurons * (numNeuronsWidestLayer - numNeurons) / 2
self.NeuronList=[]
for i in range(numNeurons):
neu = Neuron(self.positionX,positionY,radius)
neu.draw()
self.NeuronList.append(neu)
positionY = positionY + vertical_distance_between_neurons
class PlotNeuralConnection:
def __init__():
pass
# 连接两个神经元
def TwoNeuronsConnection(neuron1,neuron2):
neuron_radius= neuron1.radius
angle = atan((neuron2.y - neuron1.y)/float(neuron2.x - neuron1.x))
x_adjustment = neuron_radius * cos(angle)
y_adjustment = neuron_radius * sin(angle)
##################### 添加直线 ###########################
line = plt.Line2D((neuron1.x + x_adjustment, neuron2.x - x_adjustment), (neuron1.y + y_adjustment, neuron2.y - y_adjustment),color="#4d4d4d",linewidth=0.2)
plt.gca().add_line(line)
#########################################################
##################### 添加箭头(不好看) ###########################
# startX,startY = neuron1.x + x_adjustment,neuron1.y + y_adjustment
# deltaX,deltaY = neuron2.x - x_adjustment - startX ,neuron2.y - y_adjustment - startY
# plt.gca().arrow(startX,startY,deltaX,deltaY, width=0.001, color="#4d4d4d",
# head_width=0.01, head_length=0.05, overhang=1.0,length_includes_head=True)
#########################################################
# 连接相邻两层神经元
def TwoLayersConnection(NeuronLayer1,NeuronLayer2):
Layer1 = NeuronLayer1.NeuronList
Layer2 = NeuronLayer2.NeuronList
for neuron1,neuron2 in product(Layer1,Layer2):
TwoNeuronsConnection(neuron1,neuron2)
##############################################
radius =0.075
Layer11 = NeuronLayer(positionX=1,initY= 0.0,numNeurons=4,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.25,radius=radius)
Layer12= NeuronLayer(positionX=1,initY= 1,numNeurons=4,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.25,radius=radius)
Layer21 = NeuronLayer(positionX=2,initY= 0.0,numNeurons=10,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer22 = NeuronLayer(positionX=2,initY= 1.8,numNeurons=10,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer31 = NeuronLayer(positionX=3,initY= 0.0,numNeurons=8,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer32 = NeuronLayer(positionX=3,initY= 1.8,numNeurons=8,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer41 = NeuronLayer(positionX=4,initY= 0.0,numNeurons=5,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer42 = NeuronLayer(positionX=4,initY= 1.8,numNeurons=5,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer51 = NeuronLayer(positionX=5,initY= 0.0,numNeurons=1,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer52 = NeuronLayer(positionX=5,initY= 1.8,numNeurons=1,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer61 = NeuronLayer(positionX=6,initY= 0.0,numNeurons=1,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
Layer62 = NeuronLayer(positionX=6,initY= 1.8,numNeurons=1,numNeuronsWidestLayer=10,vertical_distance_between_neurons=0.15,radius=radius)
TwoLayersConnection(Layer11,Layer21)
TwoLayersConnection(Layer11,Layer22)
TwoLayersConnection(Layer12,Layer21)
TwoLayersConnection(Layer12,Layer22)
TwoLayersConnection(Layer21,Layer31)
TwoLayersConnection(Layer22,Layer32)
TwoLayersConnection(Layer31,Layer41)
TwoLayersConnection(Layer32,Layer42)
TwoLayersConnection(Layer41,Layer51)
TwoLayersConnection(Layer42,Layer52)
TwoLayersConnection(Layer51,Layer61)
TwoLayersConnection(Layer52,Layer62)
############################################################################################
############# 添加末尾神经元 #################################################################
posX1,posY1 = Layer52.NeuronList[0].x, Layer52.NeuronList[0].y
neu1 = Neuron(posX1,posY1 +0.2, radius=radius)
neu1.draw()
TwoNeuronsConnection(neu1,Layer62.NeuronList[0])
posX2,posY2= Layer51.NeuronList[0].x, Layer51.NeuronList[0].y
neu2 = Neuron(posX2,posY2 + 0.2, radius=radius)
neu2.draw()
TwoNeuronsConnection(neu2,Layer61.NeuronList[0])
neu3 = Neuron(posX2,posY2 - 0.2, radius=radius)
neu3.draw()
TwoNeuronsConnection(neu3,Layer61.NeuronList[0])
#############################################################################################
############ 添加神经元标识##########################################################
plt.text(Layer62.NeuronList[0].x+0.2,Layer62.NeuronList[0].y-0.05,"输出$\hat{\mu}$")
plt.text(Layer61.NeuronList[0].x+0.2,Layer61.NeuronList[0].y-0.05,"输出$\hat{\phi}/{\omega}$")
plt.text(neu2.x-0.2,neu2.y+0.15,"$log(1/{\omega})$")
############################## 添加变量名 ###########################
cnt = 1
for neu in Layer11.NeuronList:
plt.text(neu.x -0.5,neu.y-0.04,"变量{}".format(9-cnt))
cnt=cnt+1
cnt = 1
for neu in Layer12.NeuronList:
plt.text(neu.x -0.5,neu.y-0.04,"变量{}".format(5-cnt))
cnt=cnt+1
###################################################################
############################## 添加上箭头 ###########################
line1 = plt.Line2D((1, 1), (2.8,3.5),color="#4d4d4d",linewidth=0.2)
plt.gca().add_line(line1)
line2 = plt.Line2D((1, 5), (3.5,3.5),color="#4d4d4d",linewidth=0.2)
plt.gca().add_line(line2)
plt.text(2.5,3.6,"$\mu$参数通过GLM连接")
plt.gca().arrow(5,3.5, 0, -0.7, width=0.001, color="#4d4d4d",
head_width=0.05, head_length=0.05, overhang=1.0,length_includes_head=True,linewidth=0.2)
###################################################################
############################## 添加下箭头 ###########################
line1 = plt.Line2D((1, 1), (0.4,-0.3),color="#4d4d4d",linewidth=0.2)
plt.gca().add_line(line1)
line2 = plt.Line2D((1, 5), (-0.3,-0.3),color="#4d4d4d",linewidth=0.2)
plt.gca().add_line(line2)
plt.text(2.5,-0.5,"$\phi$参数通过GLM连接")
plt.gca().arrow(5,-0.3, 0, 0.7, color="#4d4d4d",
head_width=0.05, head_length=0.05, overhang=1.0,length_includes_head=True,linewidth=0.2)
###################################################################
######################### 去除画图边框 ##############################
plt.axis("scaled")
plt.axis('off')
plt.savefig("./network.pdf")
plt.show()
####################################################################
结果如下
文章来源地址https://www.toymoban.com/news/detail-852125.html
到了这里,关于python画神经网络图的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!