折线示意图
本文所指折线连接线如上图所示,详见官方文档FCN-8网络示意图:官方README
注:本文实现稍有差异,假定情况为所绘制的模块在主干网络“上方”,图中为“下方”。
使用Python接口绘制
- 在文件
PlotNeuralNet-master/pycore/tikzeng.py
中可见官方提供的绘图函数接口,实际上是返回一个字符串,在examples
提供的fcn8.tex
中可以看到以下内容:
其中第一第三行即为所需内容。\draw [connection] (between4_5) -- node {\midarrow} (score16-west-|between4_5) -- node {\midarrow} (score16-west); \draw [connection] (d32-east) -- node {\midarrow} (elt1-west); \draw [connection] (score16-east) -- node {\midarrow} (score16-east -| elt1-south) -- node {\midarrow} (elt1-south); \draw [connection] (elt1-east) -- node {\midarrow} (d16-west);
- 将其包装在
tikzeng.py
中,新增以下函数:
其中函数def to_connection_right_down( of, to): ''' Path: right, down ''' return r""" \draw [connection] ("""+of+"""-east) -- node {\midarrow} ("""+of+"""-east -| """+to+"""-north) -- node {\midarrow} ("""+to+"""-north); """ def to_connection_up_right( of, to): ''' Path: up, right ''' return r""" \draw [connection] ("""+of+"""-north) -- node {\midarrow} ("""+to+"""-west -| """+of+"""-north) -- node {\midarrow} ("""+to+"""-west); """
to_connection_right_down()
绘制从of
到to
的连接,连接路径为先向右后向下;to_connection_up_right()
以此类推。 - 在原绘图文件中添加
to_connection
语句:to_connection_up_right( "enc_5", "att4"), to_connection_right_down( "att4", "dec_5"),
效果展示
效果如下图: