GitHub链接
PlotNeutalNet
示例代码
import sys
sys.path.append('../')
from pycore.tikzeng import *
arch = [
to_head( '..' ),
to_cor(),
to_begin(),
to_Conv("conv1", 512, 64, offset="(0,0,0)", to="(0,0,0)", height=64, depth=64, width=2 ),
to_Pool("pool1", offset="(0,0,0)", to="(conv1-east)"),
to_Conv("conv2", 128, 64, offset="(1,0,0)", to="(pool1-east)", height=32, depth=32, width=2 ),
to_connection( "pool1", "conv2"),
to_Pool("pool2", offset="(0,0,0)", to="(conv2-east)", height=28, depth=28, width=1),
to_SoftMax("soft1", 10 ,"(3,0,0)", "(pool1-east)", caption="SOFT" ),
to_connection("pool2", "soft1"),
to_end()
]
def main():
namefile = str(sys.argv[0]).split('.')[0]
to_generate(arch, namefile + '.tex' )
if __name__ == '__main__':
main()

函数表
| 函数名 | 功能 |
|---|
| to_head() | 设置.tex文件位置 |
| to_cor() | 设置颜色 |
| to_begin() | 开始flag |
| to_input() | 显示输入图像 |
| to_Conv() | 卷积层 |
| to_ConvConvRelu | 含relu运算的Conv层 |
| to_UnPool() | 反池化层 |
| to_Pool() | 池化层 |
| to_ConvRes() | 含残差操作的Conv层 |
| to_ConvSoftMax() | 含Softmax激活函数的Conv层 |
| to_SoftMax() | Softmax全连接 |
| to_connection() | 使用箭头有向连接指定的两层 |
| to_skip() | 添加一层带Relu激活函数的卷积层,跨连接,参数为:起始位置、中止位置,pos默认为1.25 |
| to_end() | 结束标志 |
| to_generate() | 生成.tex文件 |
模块函数表
| 函数名 | 功能 |
|---|
| *block_2ConvPool() | 卷积池化模块 |
| *block_Unconv() | 无卷积模块 |
| *block_Res() | 残差块 |
函参表
| 参数名 | 功能 |
|---|
| name=“conv1” | 该层名称(不显示) |
| s_filer | 该层的图像大小,标记于下方 |
| n_filer=(in_channel, out_channel) | 该层的输入通道和输出通道大小,标记与下侧方 |
| offset=“(x,y,z)” | 表示该层与上一层分别在三个笛卡尔系上的偏移量 |
| to=“(x,y,z)” | 表示该层的笛卡尔系坐标 |
| to=“(pool1-east)” | 表示该层在pool1层的右边 |
| width | 该层的宽度(X) |
| height | 该层的高度(Z) |
| depth | 该层的厚度(Y) |
| caption | 该层名称(显示) |
| opacity | 透明度(0到1之间) |
层间连接解释

该图转载自:
https://tcsds.github.io/2021/05/10/%E9%9D%A2%E5%90%91Python%E7%9A%84PlotNeuralNet%E6%95%99%E7%A8%8B/