Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Commit

Permalink
adds experimental normalizationOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyklee committed Oct 2, 2019
1 parent fcb096c commit 519cfe0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions p5js/NeuralNetwork/NeuralNetwork_lowres_pixels/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ function setup() {
inputs: totalPixels,
outputs: 1,
hiddenUnits: floor(totalPixels / 2),
normalizationOptions: {
inputMin: [...new Array(totalPixels).fill(0)],
inputMax: [...new Array(totalPixels).fill(255)]
},
// activationHidden: 'relu',
learningRate: 0.01,
debug: true,
Expand Down Expand Up @@ -79,12 +83,12 @@ function addExample() {
osc.freq(parseFloat(freq));
video.loadPixels();
let inputs = getInputs();
pixelBrain.data.addData(inputs, [parseFloat(freq)]);
pixelBrain.addData(inputs, [parseFloat(freq)]);
}

function trainModel() {
osc.amp(0);
pixelBrain.data.normalize();
pixelBrain.normalize();
const trainingOptions = {
epochs: 50
}
Expand All @@ -106,7 +110,7 @@ function gotFrequency(error, results) {
if (error) {
console.error(error);
} else {
frequency = parseFloat(results.outputs.value);
frequency = parseFloat(results.output[0].value);
select('#prediction').html(frequency.toFixed(2));
osc.freq(parseFloat(frequency));
predict();
Expand Down

0 comments on commit 519cfe0

Please sign in to comment.