Guest User

Untitled

a guest
Jul 17th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. const model = tf.sequential();
  2. model.add(tf.layers.dense({units: 1, inputShape: [5, 5] }));
  3. model.compile({ loss: 'binaryCrossentropy', optimizer: 'sgd' });
  4.  
  5. // Input data
  6. // Array of days, and their capacity used out of
  7. // 100% for 5 hour period
  8. const xs = tf.tensor([
  9. [11, 23, 34, 45, 96],
  10. [12, 23, 43, 56, 23],
  11. [12, 23, 56, 67, 56],
  12. [13, 34, 56, 45, 67],
  13. [12, 23, 54, 56, 78]
  14. ]);
  15.  
  16. // Labels
  17. const ys = tf.tensor([[1], [2], [3], [4], [5]]);
  18.  
  19. // Train the model using the data.
  20. model.fit(xs, ys).then(() => {
  21. model.predict(tf.tensor(5)).print();
  22. }).catch((e) => {
  23. console.log(e.message);
  24. });
  25.  
  26. model.add(tf.layers.dense({units: 1, inputShape: [5, 5] }));
  27.  
  28. model.predict(tf.tensor(5))
Add Comment
Please, Sign In to add comment