import networkx as nx import matplotlib.pyplot as plt G = nx.DiGraph() G.add_node("输入层") G.add_node("隐藏层 1") G.add_node("隐藏层 2") G.add_node("输出层") G.add_edge("输入层", "隐藏层 1") G.add_edge("输入层", "隐藏层 2") G.add_edge("隐藏层 1", "输出层") G.add_edge("隐藏层 2", "输出层") pos = nx.spring_layout(G) nx.draw_networkx(G, pos) plt.rcParams['font.sans-serif']=['SimHei'] plt.show()