🧹 NeuralNetwork cleanup pt. 3 -- tasks #1410
Open
+32,128
−53,436
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduces a level of abstraction for the "task" of the neural network:
getTask.ts
NNTask
which specifies what information a task needs to provide:noTraining
is set.name
(not currently not used, possible 🪓)classification
,regression
, andimageClassification
.imageClassification
uses some of the same functions asclassification
.getSampleData
is only possible in a limited set of circumstances (see issue NN optionnoTraining
is undocumented and buggy #1409), so I'm throwing a lot of specific errors when those circumstances aren't met.getTask
to convert astring
task name into aNNTask
object.NeuralNetwork/index.ts
this.task
with the task object based onoptions.task
. This defaults toregression
which seems to match what was in the default layers before.addDefaultLayers()
andcompile()
which was moved into the task objects. Now we call a function onthis.task
:const layers = this.task.createLayers(inputUnits, hiddenUnits, outputUnits);
const options = this.task.getCompileOptions(this.options.learningRate);
NeuralNetwork/NeuralNetwork.ts
optimizer.call(this, learningRate)
to set thethisArg
on the optimizer doesn't actually make a difference? (Please correct me if I am wrong). I removedsetOptimizerFunction()
, which, despite the name, just creates an optimizer and doesn't set anything. The instantiation of the optimizer is handled in thegetCompileOptions()
function of the task, which gets thelearningRate
as an argument.