Error when load model using tf.loadLayersModel
when run the code
(async function () {
console.log("wating for model load!");
const model = await tf.loadLayersModel("simple/model.json");
console.log("model: ", model);
})();
I got error
Uncaught (in promise) Error: Input 0 is incompatible with layer flatten_3: expected min_ndim=3, found ndim=2.
at new e (errors.ts:48)
at e.assertInputCompatibility (topology.ts:790)
at topology.ts:985
at rh (common.ts:43)
at e.apply (topology.ts:978)
at e.add (models.ts:500)
at e.fromConfig (models.ts:948)
at Rp (generic_utils.ts:277)
at cd (serialization.ts:31)
at models.ts:300
I use script tag verson 1.0.0 OR 2.0.0 same error
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
How can fix it ??
Please use latest version 3.2.0 and let us know , if that does not help , please share reproducible code in codepen or in a GitHub repo. Thank you
this is my code on github https://github.com/AmmarYasir29/tensorflowJS
I try the last verson that you tell me ans the same error:
Uncaught (in promise) Error: Input 0 is incompatible with layer flatten_3: expected min_ndim=3, found ndim=2. at t.n.assertInputCompatibility (topology.js:790)
@rthadur any help ??
i guess the model file is missing , is it fine to share the model also , thank you
I convert model from .h5 format to .json to load
embedded it to web by
console.log("wating form model load!");
const model = await tf.loadLayersModel("http://localhost:3000/fjs/model.json");
But the error appear IMG Error and I cant fix that
The mdoel in h5 format the model h5 and the json format
@rthadur the error still appear and the model not load Is there solution ?
@lina128 can you help me ?
if you are loading the model from local folder you need to use below code
model = await tf. loadLayersModel('model/model.json');
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you.
Closing as stale. Please @mention us if this needs more attention.