Last active
April 3, 2016 17:35
-
-
Save klgraham/88b455c4ea679aa058add01afda70236 to your computer and use it in GitHub Desktop.
Sign step and activation functions
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
func activate(bias: Double, bW: Double, x: [Double], w: [Double]) -> Int { | |
var sum = 0.0 | |
for i in 0..<x.count { | |
sum += x[i] * w[i] | |
} | |
sum += bias * bW | |
return step(sum) | |
} |
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
func sign(z: Double) -> Int { | |
// Note that 0 is not considered positive or negative | |
return (z > 0) ? 1 : -1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment