I’m having a problem with my tensorflow code, it won’t output anything about the prediction and losses of my model. here’s the code
const model = tf.sequential();
model.add(tf.layers.dense({ units: 4, inputShape: [3], activation: 'sigmoid' }));
model.add(tf.layers.dense({ units: 3, activation: 'sigmoid' }));
model.compile({
optimizer: tf.train.sgd(0.1),
loss: "meanSquaredError",
});
const input = tf.tensor2d([
[1,0],
[0,0],
[0,0],
]);
const target = tf.tensor2d([
[5],
[0],
[0],
]);
train().then(() => {
console.log("training complete");
const prediction = model.predict(input);
prediction.print();
});
async function train() {
for (let i = 0; i < 100; i++) {
const response = await model.fit(input, target, {
epochs: 20,
shuffle: true,
});
console.log(response.history.loss[0]);
}
}
I’ve tried tweaking, put random values in the arrays (inputs
outputs
) but I never got my expected results! which is just some loss value and the goal data
can you please see what’s wrong with my code?
thanks