August 2019
Intermediate to advanced
242 pages
5h 45m
English
As this model takes much longer to converge, we should also add a rudimentary metric to track our accuracy. In order to do this, we must first extract our labels from the data - which we can do as below:
// get label yRowT, _ := yVal.Slice(sli{j, j + 1}) yRow := yRowT.Data().([]float64) var rowLabel int var yRowHigh float64 for k := 0; k < 10; k++ { if k == 0 { rowLabel = 0 yRowHigh = yRow[k] } else if yRow[k] > yRowHigh { rowLabel = k yRowHigh = yRow[k] } }
We must then get our prediction from the output data:
yOutput2 := tensor.New(tensor.WithShape(bs, 10), tensor.WithBacking(arrayOutput2)) // get prediction predRowT, _ := yOutput2.Slice(sli{j, j + 1}) predRow := predRowT.Data().([]float64) var rowGuess int var predRowHigh float64 ...Read now
Unlock full access