Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import '@tensorflow/tf' as tf
- async function trainModel(model, inputs, labels) {
- // Prepare the model for training.
- model.compile({
- optimizer: tf.train.adam(),
- loss: tf.losses.meanSquaredError,
- metrics: ['mse'],
- });
- const batchSize = 28;
- const epochs = 50;
- return await model.fit(inputs, labels, {
- batchSize,
- epochs,
- shuffle: true,
- callbacks: tfvis.show.fitCallbacks(
- { name: 'Training Performance' },
- ['loss', 'mse'],
- { height: 200, callbacks: ['onEpochEnd'] }
- )
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement