Last active
September 4, 2019 13:47
-
-
Save etoxin/b9dc235aaab27eec89d3d53c427edcd5 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 tf = require("@tensorflow/tfjs-node"); | |
(async () => { | |
const model = tf.sequential({ | |
layers: [tf.layers.dense({ inputShape: [1], units: 1 })] | |
}); | |
model.compile({ optimizer: "sgd", loss: "meanSquaredError" }); | |
// y = 2X - 1 | |
const xs = tf.tensor([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0]); | |
const ys = tf.tensor([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0]); | |
await model.fit(xs, ys, { epochs: 1000 }); | |
model.predict(tf.tensor([10.0])).print(); | |
})(); |
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
{ | |
"main": "index.js", | |
"dependencies": { | |
"@tensorflow/tfjs-node": "^1.2.8" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment