-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrorfunction.go
More file actions
29 lines (24 loc) · 774 Bytes
/
errorfunction.go
File metadata and controls
29 lines (24 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package gorpropplus
import (
"math"
)
// SSE is the "sum of squared errors" error function
func SSE(nnResult float64, expected float64) float64 {
return 0.5 * math.Pow(expected-nnResult, 2.0)
}
// DerivateSSE is the derivate of "sum of squared errors" function
func DerivateSSE(nnResult float64, expected float64) float64 {
return nnResult - expected
}
// CE is the "cross-entropy" error function
func CE(nnResult float64, expected float64) float64 {
v := expected * math.Log(nnResult)
v2 := (1.0 - expected) * math.Log(1.0-nnResult)
return -(v + v2)
}
// DerivateCE is the derivate of CE ("cross-entropy") function
func DerivateCE(nnResult float64, expected float64) float64 {
v := (1.0 - expected) / (1.0 - nnResult)
v2 := expected / nnResult
return v - v2
}