0

I'm currently trying to load a tensorflow js model in a React app:

const modelPromise = tf.loadLayersModel('/assets/models/tfjs_model/model.json')

However, whenever I use the model I receive the error:

Model.jsx:10 Model load error _ValueError: An InputLayer should be passed either a `batchInputShape` or an `inputShape`.
at new InputLayer (@tensorflow_tfjs.js?v=d977a120:19467:15)
at fromConfig (@tensorflow_tfjs.js?v=d977a120:11535:12)
at deserializeKerasObject (@tensorflow_tfjs.js?v=d977a120:17336:25)
at deserialize (@tensorflow_tfjs.js?v=d977a120:20621:10)
at processLayer (@tensorflow_tfjs.js?v=d977a120:22010:21)
at fromConfig (@tensorflow_tfjs.js?v=d977a120:22024:7)
at deserializeKerasObject (@tensorflow_tfjs.js?v=d977a120:17336:25)
at deserialize (@tensorflow_tfjs.js?v=d977a120:20621:10)
at loadLayersModelFromIOHandler (@tensorflow_tfjs.js?v=d977a120:24066:18)

There is a batch_shape variable in the model.json file but when I change it the batchInputShape, I receive the error:

Model.jsx:10 Model load error _ValueError: Corrupted configuration, expected array for nodeData: [object Object]
at @tensorflow_tfjs.js?v=d977a120:22016:17
at Array.forEach (<anonymous>)
at processLayer (@tensorflow_tfjs.js?v=d977a120:22014:24)
at fromConfig (@tensorflow_tfjs.js?v=d977a120:22024:7)
at deserializeKerasObject (@tensorflow_tfjs.js?v=d977a120:17336:25)
at deserialize (@tensorflow_tfjs.js?v=d977a120:20621:10)
at loadLayersModelFromIOHandler (@tensorflow_tfjs.js?v=d977a120:24066:18)

Not sure how to resolve these errors.

1
  • Considering the name of the method "loadLayersModel" and the error message, it is likely that the data needs to be an array, and you wrongly provided an object. Commented Jun 8 at 16:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.