1. caffe 網絡結構可視化
http://ethereon.github.io/netscope/quickstart.html
將網絡結構復制粘貼到左側的編輯框,按Shift+Enter就可以顯示出你的網絡結構

2. caffe計算圖片的均值
使用caffe自帶的均值計算工具
./build/tools/compute_image_mean ROOT_OF_IMAGES ROOT_TO_PLACE_MEAN_FILE
第一個參數:需要計算均值的圖片路徑,格式為LMDB訓練數據
第二個參數:計算出來的結果保存路徑
./build/tools/compute_image_mean project/SqueezeNet/SqueezeNet_v1.0/test_lmdb project/SqueezeNet/SqueezeNet_v1.0/test_mean.binaryproto
python格式的均值計算
先用LMDB格式數據,計算出二進制格式均值,然后轉換成python格式均值
#!/usr/bin/env python
import numpy as np
import sys,caffe
if len(sys.argv)!=3:
print "Usage: python convert_mean.py mean.binaryproto mean.npy"
sys.exit()
blob = caffe.proto.caffe_pb2.BlobProto()
bin_mean = open( sys.argv[1] , 'rb' ).read()
blob.ParseFromString(bin_mean)
arr = np.array( caffe.io.blobproto_to_array(blob) )
npy_mean = arr[0]
np.save( sys.argv[2] , npy_mean )
腳本保存為convert_mean.py
調用格式:
sudo python convert_mean.py mean.binaryproto mean.npy
mean.npy是我們需要的python格式二進制文件
3. 可視化訓練過程中的 training/testing loss
- NVIDIA-DIGITS: caffe訓練可視化工具(數據准備,模型選擇,學習曲線可視化,多GPU訓練
- 訓練時 --solver=solver.ptototxt 2>&1 | tee train.log, 然后使用 ./tools/extra/parse_log.py train.log將其轉為兩個csv 文件分別包括train loss和test loss, 然后使用以下腳本畫圖:
import pandas as pd
from matplotlib import *
from matplotlib.pyplot import *
train_log = pd.read_csv("./lenet_train.log.train")
test_log = pd.read_csv("./lenet_train.log.test")
_, ax1 = subplots(figsize=(15, 10))
ax2 = ax1.twinx()
ax1.plot(train_log["NumIters"], train_log["loss"], alpha=0.4)
ax1.plot(test_log["NumIters"], test_log["loss"], 'g')
ax2.plot(test_log["NumIters"], test_log["acc"], 'r')
ax1.set_xlabel('iteration')
ax1.set_ylabel('train loss')
ax2.set_ylabel('test accuracy')
savefig("./train_test_image.png") #save image as png
