Skip to content

Instantly share code, notes, and snippets.

@kidtronnix
Last active September 13, 2018 19:45
Show Gist options
  • Save kidtronnix/82116c95f5b3811d491ef47c89b26a23 to your computer and use it in GitHub Desktop.
Save kidtronnix/82116c95f5b3811d491ef47c89b26a23 to your computer and use it in GitHub Desktop.
package nn
import (
"gonum.org/v1/gonum/mat"
)
func (n *MLP) Evaluate(x, y mat.Matrix) float64 {
p := n.Predict(x)
N, _ := p.Dims()
var correct int
for n := 0; n < N; n++ {
ry := mat.Row(nil, n, y)
truth = oneHotDecode(ry)
rp := mat.Row(nil, n, p)
predicted = prediction(rp)
if predicted == truth {
correct++
}
}
accuracy := float64(correct) / float64(N)
return accuracy * 100
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment