Hi,
What’s the difference in packing between Tensorflow.js version 1 and the latest version?
I try to use Tensorflow.js in Observablehq framework. Version number 1 works fine but latest don’t? It gives error message…
TypeError: t.alea is not a function
RuntimeError: t.alea is not a function
//WORKS!
import * as tf from 'npm:@tensorflow/tfjs@1';
//DON'T WORK!
import * as tf from 'npm:@tensorflow/tfjs@latest';
// Define a simple model.
const model = tf.sequential();
model.add(tf.layers.dense({units: 100, activation: 'relu', inputShape: [10]}));
model.add(tf.layers.dense({units: 1, activation: 'linear'}));
model.compile({optimizer: 'sgd', loss: 'meanSquaredError'});
const xs = tf.randomNormal([100, 10]);
const ys = tf.randomNormal([100, 1]);
// Train the model.
model.fit(xs, ys, {
epochs: 100,
callbacks: {
onEpochEnd: (epoch, log) => display(`Epoch ${epoch}: loss = ${log.loss}`)
}
});