require('@tensorflow/tfjs-node');
var tf = require('@tensorflow/tfjs');
tf.setBackend('tensorflow');
//tf.setBackend('webgl');
// Tiny TFJS train / predict example.
function myFirstTfjs() {
// Create a simple model.
const model = tf.sequential();
model.add(tf.layers.dense({units: 1, inputShape: [1]}));
// Prepare the model for training: Specify the loss and the optimizer.
model.compile({
loss: 'meanSquaredError',
optimizer: 'sgd'
});
// Generate some synthetic data for training. (y = 2x - 1)
const xs = tf.tensor2d([-1, 0, 1, 2, 3, 4], [6, 1]);
const ys = tf.tensor2d([-3, -1, 1, 3, 5, 7], [6, 1]);
// Train the model using the data.
model.fit(xs, ys, {epochs: 500});
// Use the model to do inference on a data point the model hasn't seen.
// Should print approximately 39.
var predict=
model.predict(tf.tensor2d([20], [1, 1]));
console.log( "PREDICT\n", predict );
}
myFirstTfjs()setBackendtf.setBackend('webgl');--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/43e8aaff-d390-45ac-b22f-63e5e93e61be%40tensorflow.org.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+unsubscribe@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/43e8aaff-d390-45ac-b22f-63e5e93e61be%40tensorflow.org.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/43e8aaff-d390-45ac-b22f-63e5e93e61be%40tensorflow.org.
--Dott. Ing. Loreto Parisi
Parisi Labs
Company: in...@parisilabs.comPersonal: loreto...@gmail.comTwitter: @loretoparisi
--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/CAOBZaM1X65875Lf%3DBDJq6zd9%2B%3DFpXN2cAJqOesyqcSuXmjFjAQ%40mail.gmail.com.