Created
January 8, 2018 10:36
-
-
Save plutov/7580d3fc5623cdc7efeb44269004fec7 to your computer and use it in GitHub Desktop.
tensorflow6.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment