Last active
April 4, 2016 00:45
-
-
Save klgraham/634fc13b28b7b787515a3f11113b244b to your computer and use it in GitHub Desktop.
This file contains 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(x: [Double], _ w: [Double]) -> Int { | |
var sum = 0.0 | |
for i in 0..<x.count { | |
sum += x[i] * w[i] | |
} | |
return sign(sum) | |
} |
This file contains 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