Hi TI team,
I am trying to convert LeNet trained with Caffe-Jacinto v0.16 using TIDL model import tool.
Training:
- I pulled Caffe-Jacinto v0.16 from GitHub on Ubuntu 16.04 (x64)
- I modified Makefile.config in order to use CPU_ONLY and to use ATLAS instead of BLAS
- Then i built caffe-jacinto with "make all"
- After that
./data/mnist/get_mnist.sh ./examples/mnist/create_mnist.sh ./examples/mnist/train_lenet.sh
to train the net.
My final model (after 10000 iterations) had 99.2% accuracy on test set.
This are files used for training:
https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/LeNet.7z
I also tried without
transform_param {
scale: 0.00390625
}
Converting:
I used both TIDL.00.08.00.00 and TIDL.01.00.00.00 model import tool for converting the trained Caffe-Jacinto model to TIDL model. Those are files used for converting:
https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/LeNetConverting.7z
When i run the TIDL model import tool like this
tidl_model_import.out.exe ..\..\test\testvecs\config\import\tidl_import_mnist_caffe_jacinto.txt
I get weird output of the network. As you can see from the import file, i am using MNIST test data and i am running the tool on 10 samples.
The output I get is this:
Caffe Network File : ..\..\test\testvecs\config\caffe_jacinto_models\mnist\lenet.prototxt
Caffe Model File : ..\..\test\testvecs\config\caffe_jacinto_models\mnist\lenet_iter_10000.caffemodel
TIDL Network File : ..\..\test\testvecs\config\tidl_models\mnist\tidl_mnist_caffe_jacinto_016_net.bin
TIDL Model File : ..\..\test\testvecs\config\tidl_models\mnist\tidl_mnist_caffe_jacinto_016_param.bin
Name of the Network : LeNet
Num Inputs : 1
Num of Layer Detected : 6
0, TIDL_DataLayer , data 0, -1 , 1 , x , x , x , x , x , x , x , x , 0 , 0 , 0 , 0 , 0 , 1 , 2 , 28 ,
28 , 0 ,
1, TIDL_ConvolutionLayer , conv1 1, 1 , 1 , 0 , x , x , x , x , x , x , x , 1 , 1 , 2 , 28 , 28 , 1 , 20 , 12 ,
12 , 288000 ,
2, TIDL_ConvolutionLayer , conv2 1, 1 , 1 , 1 , x , x , x , x , x , x , x , 2 , 1 , 20 , 12 , 12 , 1 , 50 , 4 ,
4 , 1600000 ,
3, TIDL_InnerProductLayer , ip1 1, 1 , 1 , 2 , x , x , x , x , x , x , x , 3 , 1 , 50 , 4 , 4 , 1 , 1 , 1 , 5
00 , 400000 ,
4, TIDL_InnerProductLayer , ip2 1, 1 , 1 , 3 , x , x , x , x , x , x , x , 4 , 1 , 1 , 1 , 500 , 1 , 1 , 1 ,
10 , 5000 ,
5, TIDL_SoftMaxLayer , prob 1, 1 , 1 , 4 , x , x , x , x , x , x , x , 5 , 1 , 1 , 1 , 10 , 1 , 1 , 1 ,
10 , 10 ,
Total Giga Macs : 0.0023
Total Giga Macs : 0.0344 @15 fps
Total Giga Macs : 0.0688 @30 fps
1 file(s) copied.
Processing config file .\tempDir\qunat_stats_config.txt !
0, TIDL_DataLayer , 0, -1 , 1 , x , x , x , x , x , x , x , x , 0 , 0 , 0 , 0 , 0 , 1 , 2 , 28 , 28 ,
1, TIDL_ConvolutionLayer , 1, 1 , 1 , 0 , x , x , x , x , x , x , x , 1 , 1 , 2 , 28 , 28 , 1 , 20 , 12 , 12 ,
2, TIDL_ConvolutionLayer , 1, 1 , 1 , 1 , x , x , x , x , x , x , x , 2 , 1 , 20 , 12 , 12 , 1 , 50 , 4 , 4 ,
3, TIDL_InnerProductLayer , 1, 1 , 1 , 2 , x , x , x , x , x , x , x , 3 , 1 , 50 , 4 , 4 , 1 , 1 , 1 , 500 ,
4, TIDL_InnerProductLayer , 1, 1 , 1 , 3 , x , x , x , x , x , x , x , 4 , 1 , 1 , 1 , 500 , 1 , 1 , 1 , 10 ,
5, TIDL_SoftMaxLayer , 1, 1 , 1 , 4 , x , x , x , x , x , x , x , 5 , 1 , 1 , 1 , 10 , 1 , 1 , 1 , 10 ,
6, TIDL_DataLayer , 0, 1 , -1 , 5 , x , x , x , x , x , x , x , 0 , 1 , 1 , 1 , 10 , 0 , 0 , 0 , 0 ,
Layer ID ,inBlkWidth ,inBlkHeight ,inBlkPitch ,outBlkWidth ,outBlkHeight,outBlkPitch ,numInChs ,numOutChs ,numProcInChs,numLclInChs ,numLclOutChs,numProcItrs ,numAccItrs
,numHorBlock ,numVerBlock ,inBlkChPitch,outBlkChPitc,alignOrNot
1 40 28 40 32 24 32 2 20 2 1 8 1 2
1 1 1120 768 1
2 24 12 24 16 8 16 20 50 20 8 8 1 3
1 1 288 128 1
Processing Frame Number : 0
Layer 1 : Max PASS : -2147483648 : 219761 Out Q : 39 , 442983, TIDL_ConvolutionLayer, PASSED #MMACs = 0.58, 0.40, 0.44, Sparsity : 23.20, 30.40
Layer 2 : Max PASS : -2147483648 : 507641 Out Q : 8 , 1023276, TIDL_ConvolutionLayer, PASSED #MMACs = 1.60, 1.78, 1.79, Sparsity : -11.81, -11.01
Layer 3 : Max PASS : -2147483648 : 10798 Out Q : 267 , 10840, TIDL_InnerProductLayer, PASSED #MMACs = 0.03, 0.00, 0.03, Sparsity : 0.00, 100.00
Layer 4 : Max PASS : -2147483648 : 47034 Out Q : 93 , 373464, TIDL_InnerProductLayer, PASSED #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Layer 5 :-------Max Index 0 : 255 ------- #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Processing Frame Number : 1
Layer 1 : Max PASS : 219761 : 195796 Out Q : 44 , 394675, TIDL_ConvolutionLayer, PASSED #MMACs = 0.58, 0.40, 0.44, Sparsity : 23.20, 30.40
Layer 2 : Max PASS : 507641 : 373450 Out Q : 9 , 927974, TIDL_ConvolutionLayer, PASSED #MMACs = 1.60, 1.78, 1.79, Sparsity : -11.81, -11.01
Layer 3 : Max PASS : 10798 : 34689 Out Q : 93 , 34825, TIDL_InnerProductLayer, PASSED #MMACs = 0.03, 0.00, 0.03, Sparsity : 0.00, 100.00
Layer 4 : Max PASS : 47034 : 46066 Out Q : 32 , 379049, TIDL_InnerProductLayer, PASSED #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Layer 5 :-------Max Index 0 : 255 ------- #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Processing Frame Number : 2
Layer 1 : Max PASS : 217365 : 217155 Out Q : 40 , 437730, TIDL_ConvolutionLayer, PASSED #MMACs = 0.58, 0.40, 0.44, Sparsity : 23.20, 30.40
Layer 2 : Max PASS : 494222 : 487886 Out Q : 8 , 1043297, TIDL_ConvolutionLayer, PASSED #MMACs = 1.60, 1.78, 1.79, Sparsity : -11.81, -11.01
Layer 3 : Max PASS : 13187 : 31407 Out Q : 92 , 31530, TIDL_InnerProductLayer, PASSED #MMACs = 0.03, 0.00, 0.03, Sparsity : 0.00, 100.00
Layer 4 : Max PASS : 46938 : -12483 Out Q : 27 , 445281, TIDL_InnerProductLayer, PASSED #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Layer 5 :-------Max Index 0 : 254 ------- #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Processing Frame Number : 3
Layer 1 : Max PASS : 217344 : 212397 Out Q : 40 , 428139, TIDL_ConvolutionLayer, PASSED #MMACs = 0.58, 0.40, 0.44, Sparsity : 23.20, 30.40
Layer 2 : Max PASS : 493589 : 534392 Out Q : 7 , 1077200, TIDL_ConvolutionLayer, PASSED #MMACs = 1.60, 1.78, 1.79, Sparsity : -11.81, -11.01
Layer 3 : Max PASS : 15009 : 55597 Out Q : 45 , 55815, TIDL_InnerProductLayer, PASSED #MMACs = 0.03, 0.00, 0.03, Sparsity : 0.00, 100.00
Layer 4 : Max PASS : 40996 : -1438 Out Q : 18 , 328924, TIDL_InnerProductLayer, PASSED #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Layer 5 :-------Max Index 3 : 255 ------- #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Processing Frame Number : 4
Layer 1 : Max PASS : 216850 : 223228 Out Q : 38 , 449971, TIDL_ConvolutionLayer, PASSED #MMACs = 0.58, 0.40, 0.44, Sparsity : 23.20, 30.40
Layer 2 : Max PASS : 497669 : 522722 Out Q : 6 , 1203510, TIDL_ConvolutionLayer, PASSED #MMACs = 1.60, 1.78, 1.79, Sparsity : -11.81, -11.01
Layer 3 : Max PASS : 19067 : 33610 Out Q : 64 , 33742, TIDL_InnerProductLayer, PASSED #MMACs = 0.03, 0.00, 0.03, Sparsity : 0.00, 100.00
Layer 4 : Max PASS : 36753 : 45671 Out Q : 23 , 361823, TIDL_InnerProductLayer, PASSED #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Layer 5 :-------Max Index 0 : 254 ------- #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Processing Frame Number : 5
Layer 1 : Max PASS : 217487 : 236129 Out Q : 36 , 475977, TIDL_ConvolutionLayer, PASSED #MMACs = 0.58, 0.40, 0.44, Sparsity : 23.20, 30.40
Layer 2 : Max PASS : 500174 : 468077 Out Q : 7 , 1028292, TIDL_ConvolutionLayer, PASSED #MMACs = 1.60, 1.78, 1.79, Sparsity : -11.81, -11.01
Layer 3 : Max PASS : 20521 : 42438 Out Q : 59 , 42604, TIDL_InnerProductLayer, PASSED #MMACs = 0.03, 0.00, 0.03, Sparsity : 0.00, 100.00
Layer 4 : Max PASS : 37644 : 272 Out Q : 20 , 378015, TIDL_InnerProductLayer, PASSED #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Layer 5 :-------Max Index 3 : 255 ------- #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Processing Frame Number : 6
Layer 1 : Max PASS : 219351 : 228737 Out Q : 38 , 461076, TIDL_ConvolutionLayer, PASSED #MMACs = 0.58, 0.40, 0.44, Sparsity : 23.20, 30.40
Layer 2 : Max PASS : 496965 : 483652 Out Q : 7 , 1132697, TIDL_ConvolutionLayer, PASSED #MMACs = 1.60, 1.78, 1.79, Sparsity : -11.81, -11.01
Layer 3 : Max PASS : 22712 : 19603 Out Q : 129 , 19680, TIDL_InnerProductLayer, PASSED #MMACs = 0.03, 0.00, 0.03, Sparsity : 0.00, 100.00
Layer 4 : Max PASS : 33907 : -26145 Out Q : 29 , 581989, TIDL_InnerProductLayer, PASSED #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Layer 5 :-------Max Index 6 : 255 ------- #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Processing Frame Number : 7
Layer 1 : Max PASS : 220289 : 230042 Out Q : 37 , 463707, TIDL_ConvolutionLayer, PASSED #MMACs = 0.58, 0.40, 0.44, Sparsity : 23.20, 30.40
Layer 2 : Max PASS : 495634 : 345923 Out Q : 7 , 1019630, TIDL_ConvolutionLayer, PASSED #MMACs = 1.60, 1.78, 1.79, Sparsity : -11.81, -11.01
Layer 3 : Max PASS : 22402 : 34403 Out Q : 73 , 34538, TIDL_InnerProductLayer, PASSED #MMACs = 0.03, 0.00, 0.03, Sparsity : 0.00, 100.00
Layer 4 : Max PASS : 27902 : 46251 Out Q : 25 , 378308, TIDL_InnerProductLayer, PASSED #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Layer 5 :-------Max Index 0 : 255 ------- #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Processing Frame Number : 8
Layer 1 : Max PASS : 221264 : 236664 Out Q : 36 , 477055, TIDL_ConvolutionLayer, PASSED #MMACs = 0.58, 0.40, 0.44, Sparsity : 23.20, 30.40
Layer 2 : Max PASS : 480663 : 476167 Out Q : 7 , 972635, TIDL_ConvolutionLayer, PASSED #MMACs = 1.60, 1.78, 1.79, Sparsity : -11.81, -11.01
Layer 3 : Max PASS : 23602 : 29096 Out Q : 87 , 29210, TIDL_InnerProductLayer, PASSED #MMACs = 0.03, 0.00, 0.03, Sparsity : 0.00, 100.00
Layer 4 : Max PASS : 29736 : -40317 Out Q : 23 , 494382, TIDL_InnerProductLayer, PASSED #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Layer 5 :-------Max Index 3 : 255 ------- #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Processing Frame Number : 9
Layer 1 : Max PASS : 222804 : 238222 Out Q : 36 , 480196, TIDL_ConvolutionLayer, PASSED #MMACs = 0.58, 0.40, 0.44, Sparsity : 23.20, 30.40
Layer 2 : Max PASS : 480214 : 581398 Out Q : 6 , 1186512, TIDL_ConvolutionLayer, PASSED #MMACs = 1.60, 1.78, 1.79, Sparsity : -11.81, -11.01
Layer 3 : Max PASS : 24151 : 30285 Out Q : 71 , 30404, TIDL_InnerProductLayer, PASSED #MMACs = 0.03, 0.00, 0.03, Sparsity : 0.00, 100.00
Layer 4 : Max PASS : 22731 : 37500 Out Q : 23 , 405700, TIDL_InnerProductLayer, PASSED #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
Layer 5 :-------Max Index 0 : 254 ------- #MMACs = 0.00, 0.00, 0.00, Sparsity : 0.00, 100.00
The network is giving the same Max Index-es always (randomly 0, 3 and 6). Also as you can notice from the output file the tool is not recognizing Pooling layers (size: 2, stride: 2), can that be a problem?
What am I doing wrong here? When i convert trained cifar-10 from https://github.com/tidsp/caffe-jacinto-models everything work as expected (it classifies test data well) but it's not same with the LeNet MNIST.
Best regards
Mladen Stupar
RT-RK
