Juliana Hill
Juliana Hill

Reputation: 440

How do I save a model using @tensorflow/tfjs-node v2?

I am struggling to get the save handler to work for saving my model. I've looked through all of stack overflow and GitHub, but no dice.

Ahhh help!!!! lol Thanks a bunch ahead of time!!! :)

Here is my model code:

const tf = require('@tensorflow/tfjs');
require('@tensorflow/tfjs-node');

const model = tf.sequential();
model.add(tf.layers.dense({ 
   units: 36,
   inputShape: [13]
}));

model.add(tf.layers.dense({ 
   units: 36, 
   activation: 'relu'
}));

model.add(tf.layers.dense({ 
   units: 1, 
   activation: 'sigmoid'
}));
    
model.compile({
   optimizer: 'adam',
   metrics: ['accuracy'],
   loss: 'meanSquaredError',
});

await model.fit(xs, ys, {
    epochs: 100
}).then(info => {
    console.log('Accuracy', info.history.acc);
});
await model.save(localhost())

Here is my package.json dependencies:

  "dependencies": {
    "@tensorflow/tfjs-node": "^2.1.0",
    "aws-sdk": "^2.695.0",
    "core-js": "^3.6.5",
    "node-fetch": "^2.6.0"
  }

Error Message:

ValueError: Cannot find any save handlers for URL

Upvotes: 4

Views: 356

Answers (1)

Barrard
Barrard

Reputation: 2043

I had same issue, Try this model.save('file://model-name');

Upvotes: 2

Related Questions