From 9d39ff94ac6003687559b427be651145a0edae04 Mon Sep 17 00:00:00 2001 From: joeyklee Date: Tue, 1 Oct 2019 23:11:35 -0400 Subject: [PATCH] adds experimental normalizationOptions object --- src/NeuralNetwork/NeuralNetworkData.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/NeuralNetwork/NeuralNetworkData.js b/src/NeuralNetwork/NeuralNetworkData.js index 659887689..ee117b1a7 100644 --- a/src/NeuralNetwork/NeuralNetworkData.js +++ b/src/NeuralNetwork/NeuralNetworkData.js @@ -25,10 +25,10 @@ class NeuralNetworkData { outputMax:null, // tensor outputMin:null, // tensor }, - inputMax:null, // array or number - inputMin:null, // array or number - outputMax:null, // array or number - outputMin:null, // array or number + inputMax: options.dataOptions.normalizationOptions.inputMax || null, // array or number + inputMin: options.dataOptions.normalizationOptions.inputMin || null, // array or number + outputMax: options.dataOptions.normalizationOptions.outputMax || null, // array or number + outputMin: options.dataOptions.normalizationOptions.outputMin || null, // array or number } } @@ -341,8 +341,8 @@ class NeuralNetworkData { } = this.convertRawToTensor(); - // inputTensor.print() - // inputTensor.print() + inputTensor.print() + inputTensor.print() // run normalize on the new tensors const { @@ -408,6 +408,15 @@ class NeuralNetworkData { outputMin = outputTensor.min(); } + // TODO: refine this custom normalization function option + // Experimental!!!! + if(this.config.dataOptions.normalizationOptions instanceof Object){ + inputMax = tf.tensor1d(this.data.inputMax); + inputMin = tf.tensor1d(this.data.inputMin); + // outputMax = tf.tensor1d(this.data.outputMax); + // outputMin = tf.tensor1d(this.data.outputMin); + } + // 5. create a normalized tensor const normalizedInputs = inputTensor.sub(inputMin).div(inputMax.sub(inputMin)); const normalizedOutputs = outputTensor.sub(outputMin).div(outputMax.sub(outputMin));