2using System.Collections.Generic;
75 List<int> rgTopShape =
new List<int>();
100 m_log.
CHECK_EQ(colBottom[0].num, colBottom[1].num,
"The bottom[0] and bottom[1] must have the same num.");
102 int nNum = colBottom[0].num;
103 int nClasses = colBottom[0].channels;
104 int nLabelDim = colBottom[1].channels;
105 float[] rgDecode =
convertF(colBottom[0].update_cpu_data());
106 float[] rgLabel =
convertF(colBottom[1].update_cpu_data());
107 int nCorrectCount = 0;
110 for (
int i = 0; i < nNum; i++)
112 int nExpectedLabel = (int)rgLabel[i * nLabelDim];
113 int nActualLabel = -1;
114 float fMin =
float.MaxValue;
116 for (
int j = 0; j < nClasses; j++)
118 float fDist = rgDecode[i * nClasses + j];
129 if (nActualLabel == nExpectedLabel)
135 double dfAccuracy = (double)nCorrectCount / (
double)nTotal;
137 colTop[0].
SetData(dfAccuracy, 0);
144 if (rgbPropagateDown[0])
145 throw new NotImplementedException();
The Log class provides general output in text form.
void CHECK_EQ(double df1, double df2, string str)
Test whether one number is equal to another.
The BlobCollection contains a list of Blobs.
void SetData(double df)
Set all blob data to the value specified.
void Reshape(int[] rgShape)
Reshapes all blobs in the collection to the given shape.
The CudaDnn object is the main interface to the Low-Level Cuda C++ DLL.
An interface for the units of computation which can be composed into a Net.
Log m_log
Specifies the Log for output.
LayerParameter m_param
Specifies the LayerParameter describing the Layer.
float convertF(T df)
Converts a generic to a float value.
LayerParameter.LayerType m_type
Specifies the Layer type.
The AccuracyDecodeLayer compares the labels output by the DecodeLayer with the expected labels output...
override void forward(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Forward compuation.
override void dispose()
Releases all GPU and host resources used by the Layer.
override void LayerSetUp(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Setup the layer.
override void backward(BlobCollection< T > colTop, List< bool > rgbPropagateDown, BlobCollection< T > colBottom)
Not implemented – AccuracyDecodeLayer cannot be used as a loss.
override void Reshape(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Reshape the bottom (input) and top (output) blobs.
override int ExactNumTopBlobs
Returns the number of top blobs: accuracy
AccuracyDecodeLayer(CudaDnn< T > cuda, Log log, LayerParameter p)
Constructor.
override int ExactNumBottomBlobs
Returns the number of bottom blobs used: predicted, label
uint top_k
When computing accuracy, count as correct by comparing the true label to the top_k scoring classes....
int axis
The 'label' axis of the prediction blob, whos argmax corresponds to the predicted label – may be nega...
bool IgnoreLabel(int nLabel)
Returns 'true' if the label is to be ignored.
Specifies the base parameter for all layers.
AccuracyParameter accuracy_param
Returns the parameter set when initialized with LayerType.ACCURACY
LayerType
Specifies the layer type.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.common namespace contains common MyCaffe classes.
BLOB_TYPE
Defines the tpe of data held by a given Blob.
The MyCaffe.layers.beta namespace contains all beta stage layers.
The MyCaffe.param namespace contains parameters used to create models.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...