Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import '@tensorflow/tf' as tf
  2. async function trainModel(model, inputs, labels) {
  3. // Prepare the model for training.
  4. model.compile({
  5. optimizer: tf.train.adam(),
  6. loss: tf.losses.meanSquaredError,
  7. metrics: ['mse'],
  8. });
  9.  
  10. const batchSize = 28;
  11. const epochs = 50;
  12.  
  13. return await model.fit(inputs, labels, {
  14. batchSize,
  15. epochs,
  16. shuffle: true,
  17. callbacks: tfvis.show.fitCallbacks(
  18. { name: 'Training Performance' },
  19. ['loss', 'mse'],
  20. { height: 200, callbacks: ['onEpochEnd'] }
  21. )
  22. });
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement