Skip to content

Commit

Permalink
adds experimental normalizationOptions object
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyklee committed Oct 2, 2019
1 parent 72a9440 commit 9d39ff9
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/NeuralNetwork/NeuralNetworkData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -341,8 +341,8 @@ class NeuralNetworkData {
} = this.convertRawToTensor();


// inputTensor.print()
// inputTensor.print()
inputTensor.print()
inputTensor.print()

// run normalize on the new tensors
const {
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 9d39ff9

Please sign in to comment.