Created
August 14, 2019 15:30
-
-
Save kirill-fedyanin/a6be50051fa9a5abbeb865ac6c524435 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const model = tf.sequential(); | |
model.add(tf.layers.dense({ units: 5, activation: 'sigmoid', inputShape: [1]})); | |
model.add(tf.layers.dense({ units: 1, activation: 'sigmoid'})); | |
model.compile({loss: 'meanSquaredError', optimizer: 'adadelta'}); | |
const xs = tf.tensor1d([1, 2, 3, 4, 5, 6, 7, 8, 9]); | |
const ys = tf.tensor1d([0, 0, 0, 0, 0, 1, 1, 1, 1]); | |
model.fit(xs, ys, {epochs: 1000}).then(h => { | |
console.log("Loss after Epoch " + " : " + h.history.loss[0]); | |
model.predict(xs).print(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment