From bb1f33310b053abdf53947322732e98261d4e5ec Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 22 Jul 2018 13:48:30 +0200 Subject: [PATCH 1/2] Added complex early stopping based on schedule function --- docs/docs/important/train/index.html | 226 +++++++++++++-------------- src/architecture/network.js | 6 +- 2 files changed, 117 insertions(+), 115 deletions(-) diff --git a/docs/docs/important/train/index.html b/docs/docs/important/train/index.html index 1ace127..5139346 100644 --- a/docs/docs/important/train/index.html +++ b/docs/docs/important/train/index.html @@ -5,17 +5,17 @@ - + - - + + - - + + - + @@ -81,174 +81,174 @@ - +
- +
@@ -290,7 +290,7 @@

Options

  • dropout - Sets the dropout of the hidden network nodes. Read more about it on the regularization page. Default: 0.
  • shuffle - When set to true, will shuffle the training data every iteration. A good option to use if your network is performing less in cross validation than in the real training set. Default: false
  • iterations - Sets the amount of iterations the process will maximally run, even when the target error has not been reached. Default: NaN
  • -
  • schedule - You can schedule tasks to happen every n iterations. An example of usage is schedule : { function: function(data){console.log(Date.now, data.error)}, iterations: 5}. This will log the time and error every 5 iterations. This option allows for complex scheduled tasks during training.
  • +
  • schedule - You can schedule tasks to happen every n iterations. An example of usage is schedule : { function: function(data){console.log(Date.now, data.error)}, iterations: 5}. This will log the time and error every 5 iterations. If the function returns false, training will stop. This option allows for complex scheduled tasks during training and for complex early stopping.
  • clear - If set to true, will clear the network after every activation. This is useful for training LSTM's, more importantly for timeseries prediction. Default: false
  • momentum - Sets the momentum of the weight change. More info here. Default: 0
  • ratePolicy - Sets the rate policy for your training. This allows your rate to be dynamic, see the rate policies page. Default: methods.rate.FIXED()
  • @@ -357,46 +357,46 @@

    Cross-validation

    - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - \ No newline at end of file + diff --git a/src/architecture/network.js b/src/architecture/network.js index 4bd7a66..89c1ad3 100644 --- a/src/architecture/network.js +++ b/src/architecture/network.js @@ -588,7 +588,8 @@ Network.prototype = { } if (options.schedule && iteration % options.schedule.iterations === 0) { - options.schedule.function({ error: error, iteration: iteration }); + var scheduleResult = options.schedule.function({ error: error, iteration: iteration }); + if (scheduleResult == false) break; } } @@ -947,7 +948,8 @@ Network.prototype = { } if (options.schedule && neat.generation % options.schedule.iterations === 0) { - options.schedule.function({ fitness: fitness, error: -error, iteration: neat.generation }); + var scheduleResult = options.schedule.function({ fitness: fitness, error: -error, iteration: neat.generation }); + if (scheduleResult == false) break; } } From 79952754f7cff418bd8c0fca2c6a79694a998826 Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 22 Jul 2018 14:01:59 +0200 Subject: [PATCH 2/2] Added complex early stopping using schedule function --- src/architecture/network.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/architecture/network.js b/src/architecture/network.js index 89c1ad3..6b6d7ce 100644 --- a/src/architecture/network.js +++ b/src/architecture/network.js @@ -589,7 +589,7 @@ Network.prototype = { if (options.schedule && iteration % options.schedule.iterations === 0) { var scheduleResult = options.schedule.function({ error: error, iteration: iteration }); - if (scheduleResult == false) break; + if (scheduleResult === false) break; } } @@ -949,7 +949,7 @@ Network.prototype = { if (options.schedule && neat.generation % options.schedule.iterations === 0) { var scheduleResult = options.schedule.function({ fitness: fitness, error: -error, iteration: neat.generation }); - if (scheduleResult == false) break; + if (scheduleResult === false) break; } }