Skip to content

Instantly share code, notes, and snippets.

@jknthn
Created September 26, 2017 07:19
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 jknthn/e8a2bac043f327225e335cf98c24ff3e to your computer and use it in GitHub Desktop.
Save jknthn/e8a2bac043f327225e335cf98c24ff3e to your computer and use it in GitHub Desktop.
class Layer {
...
var weights: Matrix!
var biases: Matrix!
var previousLayer: Layer?
var nextLayer: Layer?
func initialize(previous: Layer?, next: Layer?) {
if let previous = previous {
weights = Matrix(random: Shape(rows: size, columns: previous.size), multiplier: 0.01)
biases = Matrix(zeros: Shape(rows: size, columns: 1))
}
previousLayer = previous
nextLayer = next
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment