Reference documents:
The overall process of caffe
Prepare data ==> define Net ==> configure Solver ==> Run ==> analyze results
Draw a graphical representation of the network structure
Enter the location of the prototxt file of the network model, run the following command, and xxx.png will be output at the current location
python ~/caffe/python/draw_net.py xxx.prototxt xxx.png --rankdir=BT
# BT=Bottom to Top,该参数还可以为TB,LR,RL等
caffe command
Caffe can be followed by 4 commands:
- train: training
caffe train -solver lenet_solver.prototxt
#保存训练log文件
caffe train -solver lenet_solver.prototxt 2>1 | tee train.log #屏幕没有输出
caffe train -solver lenet_solver.prototxt 2>&1 | tee train.log #屏幕也有输出
#2>1是重定向错误输出到标准输出
- test
- device_query
- time: evaluation model running time
caffe time -model lenet.prototxt -iterations 100 # cpu上跑
caffe time -model lenet.prototxt -iterations 100 -gpu 0 # 0号GPU上跑
draw loss curve
Save the training log file first, then
- Method 1: Directly use plot_training_log.py.example in caffe/tools/extra
Input: python tools/extra/plot_training_log.py.example will output the usage information of this function
Usage:
./plot_training_log.py chart_type[0-7] /where/to/save.png /path/to/first.log ...
Notes:
1. Supporting multiple logs.
2. Log file name must end with the lower-cased ".log".
Supported chart types:
0: Test accuracy vs. Iters
1: Test accuracy vs. Seconds
2: Test loss vs. Iters
3: Test loss vs. Seconds
4: Train learning rate vs. Iters
5: Train learning rate vs. Seconds
6: Train loss vs. Iters
7: Train loss vs. Seconds
For example:
python tools/extra/plot_training_log.py.example 6 loss.png path/to/train.log
#会在当前目录生成train.log.train, tarin.log.test两个解析出的文件和loss.png图片
- Method 2: Use parse_log.py in caffe/tools/extra to parse out the log.train and log.test files, and then use matplotlib to draw them yourself
usage:
python tools/extra/parse_log.py logfile_path output_dir