[OpenR8 solution] XOR_Caffe_FC (Learn XOR rules with Caffe)
  1. Chapter1: XOR_Caffe_FC introduction

 

XOR_Caffe_FC is to use the Caffe framework to determine the XOR value of two numbers. The relationship between the input value and the output value is shown in Fig. 1.

 

The solution is to use the caffe framework to determine the XOR value of two numbers. First, prepare the learning data, train the model to find the rules, and finally enter the number to verify whether the training is successful. See Fig. 2.

 

Fig. 1. XOR value.png

Fig. 1. XOR value.

 

Fig. 2. XOR_Caffe_FC flow.png

Fig. 2. XOR_Caffe_FC flow.

 

 

  1. Chapter2: XOR_Caffe_FC folder introduction

 

XOR_Caffe_FC is located in the solution folder of OpenR8, as shown in Fig. 3, with three flow files and one data folder, Fig. 4.

 

Fig. 3. XOR_Caffe_FC location.png

Fig. 3. XOR_Caffe_FC location.

 

Fig. 4. XOR_Caffe_FC folder.png

Fig. 4. XOR_Caffe_FC folder.

 

【data folder】

 

Fig. 5. Data folder of XOR_Caffe_FC.png

Fig. 5. Data folder of XOR_Caffe_FC.

 

data folder content

Use

test_lmdb

Execute the database generated by 1_create_lmdb.flow.

train_lmdb

Execute the database generated by 1_create_lmdb.flow.

deploy.prototxt

The Caffe_XOR_ read network of 3_inference.flow will be used.

snapshot_iter_1000.caffemodel

Execute the caffemodel generated by 2_train.flow.

snapshot_iter_1000.solverstate

Execute the solverstate generated by 2_train.flow.

solver.prototxt

The caffe_ training for 2_train.flow will be used.

train-test.prototxt

Used by caffe.

xor.txt xor_2.txt

To train the XOR rule data, which stores the XOR input and output, as shown in Fig. 6.

 

Fig. 6. XOR relationship.png

Fig. 6. XOR relationship.

 

※Extension application: Change the input and output relationship of XOR.txt to train different effects (for example, training XNOR relationship).

 

 

  1. Chapter3: 1_create_lmdb.flow — Gather data into data sets

 

Please double-click “R8_Python3.6_CPU.bat or R8_Python3.6_GPU.bat” => “File”=> “Open” => “Enter the solution under OpenR8” => “Select XOR_Caffe_FC folder” => “Select 1_create_lmdb.flow”, as shown in Fig. 7, Fig. 8.

 

Fig. 7. Select 1_create_lmdb.flow.png

Fig. 7. Select 1_create_lmdb.flow.

 

Fig. 8. Load 1_create_lmdb.flow.png

Fig. 8. Load 1_create_lmdb.flow.

 

Press Run to gather the data into a data set, as shown in Fig. 9.

 

Fig. 9. Results of the operation.png

Fig. 9. Results of the operation.

 

※ When you delete the train_lmdb folder and the test_lmdb folder, press Yes.

 

Then proceed to the next step of training.

 

 

  1. Chapter4: 2_train.flow — training

 

Please double-click “R8_Python3.6_CPU.bat or R8_Python3.6_GPU.bat” => “File”=> “Open” => “Enter the solution under OpenR8” => “Select XOR_Caffe_FC folder” => “Select 2_train.flow”, as shown in Fig. 10, Fig. 11.

 

Fig. 10. Select 2_train.flow.png

Fig. 10. Select 2_train.flow.

 

Fig. 11. Load 2_train.flow.png

Fig. 11. Load 2_train.flow.

 

Press Run to start training, as shown in Fig. 12.

 

Fig. 12. Results of the operation.png

Fig. 12. Results of the operation.

 

After the training is completed, test the results of the training.

 

 

  1. Chapter5: 3_inference.flow — Test training results

 

Please double-click “R8_Python3.6_CPU.bat or R8_Python3.6_GPU.bat” => “File”=> “Open” => “Enter the solution under OpenR8” => “Select XOR_Caffe_FC folder” => “Load 3_inference.flow”, as shown in Fig. 13, Fig. 14.

 

Fig. 13. Select 3_inference.flow.png

Fig. 13. Select 3_inference.flow.

 

Fig. 14. Load 3_inference.flow.png

Fig. 14. Load 3_inference.flow.

 

You can fill in input1 and input2 to see the result of XOR, as shown in Fig. 15.

 

Fig. 15. Fill in the input.png

Fig. 15. Fill in the input.

 

Taking Fig. 15 as an example, input1 = 0, input2 = 1, press the execution to see the value of XOR of input1 and input2, as shown in Fig. 16.

 

Fig. 16. Results of the operation.png

Fig. 16. Results of the operation.

 

※ The user can change the values of input1 and input2 to see if the training is successful.


Recommended Article

1.
OpenR8 Community Edition - AI Software for Everyone (Free Download)