Skip to content

Is it possible to train the model in chunks? #933

Answered by voidvoxel
el-esnawy asked this question in Q&A
Discussion options

You must be logged in to vote

Here's the code I used to test it on my local machine in case you'd like to try it too! 💕

// Define some inputs.
const inputs = [
  [0, 0], [0, 1], [1, 0], [1, 1]
];

// Define some outputs.
const outputs = [
  0, 1, 1, 0
];

// Map the inputs to the outputs.
const trainingData = inputs.map(
  (value, index) => ({input: value, output: [ outputs[index] ] })
);

// Create a new neural network.
let xornet = new brain.NeuralNetworkGPU(
  {
    inputSize: 2,
    hiddenLayers: [3],
    outputSize: 1
  }
);

// Train the network.
let results = xornet.train(
  trainingData, {
    iterations: 25000,
    errorThresh: 0.011
  }
);

// Log the results.
console.log(results);

// Save it to JSON and th…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@el-esnawy
Comment options

@voidvoxel
Comment options

Answer selected by el-esnawy
@voidvoxel
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants