Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const model = tf.sequential();
- model.add(tf.layers.dense({units: 1, inputShape: [5, 5] }));
- model.compile({ loss: 'binaryCrossentropy', optimizer: 'sgd' });
- // Input data
- // Array of days, and their capacity used out of
- // 100% for 5 hour period
- const xs = tf.tensor([
- [11, 23, 34, 45, 96],
- [12, 23, 43, 56, 23],
- [12, 23, 56, 67, 56],
- [13, 34, 56, 45, 67],
- [12, 23, 54, 56, 78]
- ]);
- // Labels
- const ys = tf.tensor([[1], [2], [3], [4], [5]]);
- // Train the model using the data.
- model.fit(xs, ys).then(() => {
- model.predict(tf.tensor(5)).print();
- }).catch((e) => {
- console.log(e.message);
- });
- model.add(tf.layers.dense({units: 1, inputShape: [5, 5] }));
- model.predict(tf.tensor(5))
Add Comment
Please, Sign In to add comment