1. 程式人生 > >caffe權值視覺化,特徵視覺化,網路模型視覺化

caffe權值視覺化,特徵視覺化,網路模型視覺化

--------------------------------------------------------------------------------

權值視覺化

對訓練後的網路權值進行視覺化可以判斷模型的優劣及是否欠(過)擬合。經過良好訓練的網路權值通常表現為美觀,光滑;反之則表現為噪聲影象,或者圖案相關性太高(很規則的點和條紋),或者缺乏結構性,或有較多‘死’區域。

[email protected]:~$ cd caffe


[email protected]:~/caffe$ cd python


[email protected]:~/caffe/python$

ls
caffe        CMakeLists.txt  detect.py    lenet_iter_10000.caffemodel  mnist_deploy.prototxt  requirements.txt         test_extract_weights.py~
classify.py  conv2.jpg       draw_net.py  lenet_train_test.prototxt    mnist.jpg             test_extract_weights.py


[email protected]:~/caffe/python$ python test_extract_weights.py

結果:[('conv1', (20, 1, 5, 5)), ('conv2', (50, 20, 5, 5)), ('ip1', (500, 800)), ('ip2', (10, 500))]

20 5*5 convolution kernel,以1維作為輸入.

50 5*5 convolution kernel,以20維作為輸入.
------------------------------------------------------------------------------

特徵視覺化

[email protected]:~$ cd caffe


[email protected]

:~/caffe$ cd python


[email protected]:~/caffe/python$ python test_extract_data.py

------------------------------------------------------------------------------

網路模型視覺化

方法1:用程式碼:caffe / python / draw_net.py 

//進入caffe / python 才可以執行其中的python指令碼

[email protected]:~$ cd caffe


[email protected]:~/caffe$
cd python

[email protected]:~/caffe/python$ ls

caffe  classify.py  CMakeLists.txt  detect.py  draw_net.py  requirements.txt


[email protected]:~/caffe/python$ ./draw_net.py
usage: draw_net.py [-h] [--rankdir RANKDIR] [--phase PHASE]
                   input_net_proto_file output_image_file
draw_net.py: error: too few arguments    //不用理會error

[email protected]:~/caffe/python$ ./draw_net.py --rankdir TB ./lenet_train_test.prototxt mnist.jpg  

Drawing net to mnist.jpg

//TB=top to bottom;網路模型:lenet_train_test.prototxt;儲存到mnist.jpg






20 5*5 convolution kernel,以1為步長滑動.

方法2.線上視覺化工具 http://ethereon.github.io/netscope/#/editor

shift鍵+回車,就可以畫圖了。

把原來的刪除,把網路模型:lenet_train_test.prototxt程式碼複製過去


-----------------------------------------------------------------------------

視覺化accuracy / loss曲線

step1:把這個檔案copy到caffe/python,改名字為:plot_training_log.py


step2:save training phase 列印到螢幕的資訊

$ sh train_lenet.sh >& 1.log