Accuracy Measurement Tool
The open-source tool Octave is introduced to analyze the relative error in a visualized manner.
Make the following preparations:
- Construct data: actual value and measured value. The actual value is typically the NumPy data, and the measured value is the operator output. Both values can be generated using ST cases.
- Install Octave: Download the installation package from https://www.gnu.org/software/octave/download.html.
The following describes the procedure of analyzing the relative error with Octave.
Figure 1 Example data.csv file
- Load data.
m = dlmread('data.csv', ',');Load the data in the file to matrix m, where, data.csv is the name of the data file, and ',' is the file separator.
- Read data.
input = m(4:8940, 7); // Read all data in column 7. gpu_output = m(4:8940, 13); // Read all data in column 13. model_output = m(4:8940, 19); // Read all data in column 19.
- Calculate the relative error and absolute error.
gpu_diff = abs(model_output - gpu_output); // Calculate the absolute error. gpu_error = gpu_diff / gpu_output; // Calculate the relative error.
In the preceding command, gpu_output is the actual value, and model_output is the measured value.
- Visualize the result.
plot(input, gpu_error, 'o'); xlabel('x') //x-axis label ylabel('value'); //y-axis label title(''Diff of model and cpu or gpu); //title hold on; //Draw again. plot (x, cpu_error, 'o'); //The process of cpu_error is omitted here, which is similar to that of gpu_error. hold off; Axis([0 1 -0.002 0.002]); // x-axis and y-axis ranges legend('gpu_error','cpu_error'); //LegendThe following figure shows a visualized result example.
Figure 2 Visualized result using Octave
Parent topic: TBE Operator Accuracy Tuning