Skip to content

Commit

Permalink
Create train.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Jun 1, 2024
1 parent 6205d07 commit dc1f5d3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ai/models/model/train.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const tf = require('@tensorflow/tfjs');
const model = require('./galactic_chain_model');

async function train() {
const xs = tf.tensor2d([-1, 0, 1, 2, 3, 4], [6, 1]);
const ys = tf.tensor2d([-3, -1, 1, 3, 5, 7], [6, 1]);

model.compile({ optimizer: tf.optimizers.sgd(), loss: 'eanSquaredError' });

await model.fit(xs, ys, { epochs: 100 });

console.log('Model trained!');
}

train();

0 comments on commit dc1f5d3

Please sign in to comment.