Tfjs: How to use sharded weights with a trained model in a react native tensorflow app

Created on 13 Apr 2020  路  2Comments  路  Source: tensorflow/tfjs

To get help from the community, we encourage using Stack Overflow and the tensorflow.js tag.

TensorFlow.js version

"@tensorflow/tfjs": "^1.6.0",
"@tensorflow/tfjs-converter": "^1.7.2",
"@tensorflow/tfjs-react-native": "^0.2.3",

Browser version

"react-native": "~0.61.4",

Describe the problem or feature request

Load sharded models or group sharded models to ship with react native bundle.

I'm seeing the following error when trying to load a converted saved model into my react native app using bundleResourceIO:

     [Error: Based on the provided shape, [1,1,160,960], the tensor should have 153600 values but has 107172]

I noticed that bundleResourceIO requires a single weights file, and cannot load sharded weights. I believe this is the source of my problem, as the model isn't even finishing loading when the error is thrown. Is there away to convert a python saved model without sharding the weights?

others

Most helpful comment

Yes sharded weights are not supported in the bundlerResource loader. You can use the --weight_shard_size_bytes option in the converter to adjust the shard size, set it to a value larger than your model and you should get one shard.

All 2 comments

Yes sharded weights are not supported in the bundlerResource loader. You can use the --weight_shard_size_bytes option in the converter to adjust the shard size, set it to a value larger than your model and you should get one shard.

@tafsiri that worked. Thank you for pointing me to that....I would've been searching all day otherwise!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

weiji14 picture weiji14  路  3Comments

rumschuettel picture rumschuettel  路  3Comments

dhrumil83 picture dhrumil83  路  3Comments

kylemcdonald picture kylemcdonald  路  3Comments

lastnod picture lastnod  路  3Comments