September 2018
Intermediate to advanced
328 pages
10h 46m
English
Predicting data in this instance means predicting the argmax value. To do this, we assume that the last layer of the network is a SoftmaxLayer. Prediction occurs when we call the GetPrediction()
function, as follows:
public int[] GetPrediction(){var softmaxLayer = this._lastLayer as SoftmaxLayer<T>;if (softmaxLayer == null){throw new Exception("Function assumes softmax as last layer of the net!");}var activation = softmaxLayer.OutputActivation;var N = activation.Shape.Dimensions[3];var C = activation.Shape.Dimensions[2];var result = new int[N];for (varn = 0; n < N; n++){varmaxv = activation.Get(0, 0, 0, n);varmaxi = 0;for (vari = 1; i < C; i++){var output = activation.Get(0, 0, i, n);if (Ops<T>.GreaterThan(output, maxv))Read now
Unlock full access