Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. /**
  2. * @desc trains model
  3. * @return trained model
  4. */
  5. async function trainModelFunction(model, inputs, outputs, epochs) {
  6. model.compile({
  7. optimizer: tf.train.adam(),
  8. loss: 'categoricalCrossentropy',
  9. metrics: ['accuracy'],
  10. });
  11.  
  12. const batchSize = 64;
  13.  
  14. return await model.fit(inputs, outputs, {
  15. batchSize,
  16. epochs,
  17. shuffle: true,
  18. callbacks: tfvis.show.fitCallbacks(
  19. { name: 'Training Performance' },
  20. ['loss', 'accuracy'],
  21. { height: 200, callbacks: ['onEpochEnd'] }
  22. )
  23. });
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement