Skip to content

Instantly share code, notes, and snippets.

@klgraham
Last active April 3, 2016 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klgraham/88b455c4ea679aa058add01afda70236 to your computer and use it in GitHub Desktop.
Save klgraham/88b455c4ea679aa058add01afda70236 to your computer and use it in GitHub Desktop.
Sign step and activation functions
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)
}
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