CConfusionMatrixLayer Class
June 14, 2020 ยท View on GitHub
This class implements a layer that calculates the Confusion Matrix for classification results.
Confusion Matrix is a square matrix of the size equal to the number of classes. The columns correspond to the classes determined by the network, the rows - to the actual classes to which the objects belong. Each element contains the number of objects which belong to the row class and were classified as the column class.
If classification was correct for all objects, the confusion matrix should be diagonal (all non-diagonal elements equal to 0).
Settings
Resetting the matrix after each run
void SetReset( const bool value );
Specifies if the matrix should be reset (filled with zeros) after each network run. By default, the reset is turned on.
If you turn off this setting, the matrix will contain the total results since the last reset.
Manual reset
void ResetMatrix();
Resets all matrix elements to 0.
Trainable parameters
The layer has no trainable parameters.
Inputs
The layer has two inputs. The first input accepts a blob with the network response, of the dimensions:
BatchLength * BatchWidth * ListSizeis equal to the number of objects that were classified.Height,Width, andDepthare equal to1.Channelsis equal to the number of classes (and should be greater than1).
The second input accepts a blob with the correct classes for the objects. Its dimensions should be the same.
Outputs
The single output returns a blob of the dimensions:
BatchLength,BatchWidth,ListSize,Depth, andChannelsare equal to1.HeightandWidthare equal to the inputChannels.
The column number in the matrix means the class to which the network assigned the object; the row number means the correct class.
If you have set SetReset() to false, the layer will accumulate the data for all network runs until you reset it manually.