Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a1125a6

Browse files
committed
Removed extraneous threshold parameter from train(); put delta calculation in correct layer order for multi-layer networks
1 parent 16014a8 commit a1125a6

File tree

1 file changed

+2
-2
lines changed
  • Classic Computer Science Problems in Swift.playground/Pages/Chapter 7.xcplaygroundpage

1 file changed

+2
-2
lines changed

‎Classic Computer Science Problems in Swift.playground/Pages/Chapter 7.xcplaygroundpage/Contents.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class Network {
201201
//calculate delta for output layer neurons
202202
layers.last?.calculateDeltasForOutputLayer(expected: expected)
203203
//calculate delta for prior layers
204-
for l in 1..<layers.count - 1 {
204+
for l in (1..<layers.count - 1).reversed() {
205205
layers[l].calculateDeltasForHiddenLayer(nextLayer: layers[l + 1])
206206
}
207207
}
@@ -222,7 +222,7 @@ class Network {
222222
/// train() uses the results of outputs() run over
223223
/// many *inputs* and compared against *expecteds* to feed
224224
/// backpropagate() and updateWeights()
225-
func train(inputs: [[Double]], expecteds: [[Double]], printError: Bool = false, threshold:Double?=nil) {
225+
func train(inputs: [[Double]], expecteds: [[Double]], printError: Bool = false) {
226226
for (location, xs) in inputs.enumerated() {
227227
let ys = expecteds[location]
228228
let outs = outputs(input: xs)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /