前提準(zhǔn)備
1、下載MikTeX
下載鏈接: MikTeX ( https://miktex.org/download )
2、下載Git bash
下載鏈接: Git bash ( https://git-scm.com/download/win )
3、下載PlotNeuralNet
下載鏈接: PlotNeuralNet ( https://github.com/HarisIqbal88/PlotNeuralNet?tab=readme-ov-file )
進(jìn)行測(cè)試
1、解壓PlotNeuralNet-master.zip
將下載的PlotNeuralNet-master.zip解壓到當(dāng)前文件夾,并把解壓的PlotNeuralNet-master文件夾更名為PlotNeuralNet。PlotNeuralNet文件夾里的文件如下:
2、打開Git bash
- 在PlotNeuralNet文件夾里空白處右擊鼠標(biāo),找到Git Bash Here,點(diǎn)擊進(jìn)入。如下圖所示:
- 輸入以下命令在PlotNeuralNet文件夾創(chuàng)建一個(gè)新的文件夾my_project:
mkdir my_project
- 輸入以下命令將Git bash 里的路徑切換到文件夾my_project:
cd my_project
- 輸入以下命令使用vim編寫my_arch.py:
vim my_arch.py
- 將以下代碼復(fù)制進(jìn)去
import sys
sys.path.append('../')
from pycore.tikzeng import *
# defined your arch
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()
- 代碼復(fù)制完后,按
Esc
鍵,然后再按:wq
后回車保存退出。 - 執(zhí)行以下命令
bash ../tikzmake.sh my_arch
- 宏包安裝
在彈出的窗口界面安裝宏包
【可能的報(bào)錯(cuò)】
如果在Git bash 中輸出以下報(bào)錯(cuò):
! LaTeX Error: File ’import.sty‘ not found. Type X to quit or to proceed, or enter new name. (Default extension: sty) Enter file name:
【解決方式】
1、直接關(guān)閉Git bash
2、找到并打開MikTex Console
3、按下圖進(jìn)行操作
4、執(zhí)行以下命令
bash ../tikzmake.sh my_arch
3、 在my_project中查看生成的pdf文件
創(chuàng)建自己的神經(jīng)網(wǎng)絡(luò)結(jié)構(gòu)可視化圖形
找到pyexamples文件夾下的test_simple.py或unet.py文件,更改defined your arch部分,運(yùn)行代碼后會(huì)生成一個(gè).tex文件,運(yùn)行.tex文件即可得到自己的可視化模型的pdf文件。test_simple.py中的defined your arch部分:
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-857310.html
# defined your arch
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_Sum("sum1", offset="(1.5,0,0)", to="(soft1-east)", radius=2.5, opacity=0.6),
to_connection("soft1", "sum1"),
to_end()
]
unet.py中的defined your arch部分:
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-857310.html
arch = [
to_head('..'),
to_cor(),
to_begin(),
#input
to_input( '../examples/fcn8s/cats.jpg' ),
#block-001
to_ConvConvRelu( name='ccr_b1', s_filer=500, n_filer=(64,64), offset="(0,0,0)", to="(0,0,0)", width=(2,2), height=40, depth=40 ),
to_Pool(name="pool_b1", offset="(0,0,0)", to="(ccr_b1-east)", width=1, height=32, depth=32, opacity=0.5),
*block_2ConvPool( name='b2', botton='pool_b1', top='pool_b2', s_filer=256, n_filer=128, offset="(1,0,0)", size=(32,32,3.5), opacity=0.5 ),
*block_2ConvPool( name='b3', botton='pool_b2', top='pool_b3', s_filer=128, n_filer=256, offset="(1,0,0)", size=(25,25,4.5), opacity=0.5 ),
*block_2ConvPool( name='b4', botton='pool_b3', top='pool_b4', s_filer=64, n_filer=512, offset="(1,0,0)", size=(16,16,5.5), opacity=0.5 ),
#Bottleneck
#block-005
to_ConvConvRelu( name='ccr_b5', s_filer=32, n_filer=(1024,1024), offset="(2,0,0)", to="(pool_b4-east)", width=(8,8), height=8, depth=8, caption="Bottleneck" ),
to_connection( "pool_b4", "ccr_b5"),
#Decoder
*block_Unconv( name="b6", botton="ccr_b5", top='end_b6', s_filer=64, n_filer=512, offset="(2.1,0,0)", size=(16,16,5.0), opacity=0.5 ),
to_skip( of='ccr_b4', to='ccr_res_b6', pos=1.25),
*block_Unconv( name="b7", botton="end_b6", top='end_b7', s_filer=128, n_filer=256, offset="(2.1,0,0)", size=(25,25,4.5), opacity=0.5 ),
to_skip( of='ccr_b3', to='ccr_res_b7', pos=1.25),
*block_Unconv( name="b8", botton="end_b7", top='end_b8', s_filer=256, n_filer=128, offset="(2.1,0,0)", size=(32,32,3.5), opacity=0.5 ),
to_skip( of='ccr_b2', to='ccr_res_b8', pos=1.25),
*block_Unconv( name="b9", botton="end_b8", top='end_b9', s_filer=512, n_filer=64, offset="(2.1,0,0)", size=(40,40,2.5), opacity=0.5 ),
to_skip( of='ccr_b1', to='ccr_res_b9', pos=1.25),
to_ConvSoftMax( name="soft1", s_filer=512, offset="(0.75,0,0)", to="(end_b9-east)", width=1, height=40, depth=40, caption="SOFT" ),
to_connection( "end_b9", "soft1"),
to_end()
]
到了這里,關(guān)于【神經(jīng)網(wǎng)絡(luò)結(jié)構(gòu)可視化】PlotNeuralNet的安裝、測(cè)試及創(chuàng)建自己的神經(jīng)網(wǎng)絡(luò)結(jié)構(gòu)可視化圖形的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!