Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- res := getTopFiveLabels(labels, output[0].Value().([][]float32)[0])
- for _, l := range res {
- fmt.Printf("label: %s, probability: %.2f%%\n", l.Label, l.Probability*100)
- }
- func getTopFiveLabels(labels []string, probabilities []float32) []Label {
- var resultLabels []Label
- for i, p := range probabilities {
- if i >= len(labels) {
- break
- }
- resultLabels = append(resultLabels, Label{Label: labels[i], Probability: p})
- }
- sort.Sort(Labels(resultLabels))
- return resultLabels[:5]
- }
Add Comment
Please, Sign In to add comment