tfbook icon indicating copy to clipboard operation
tfbook copied to clipboard

Error in colab chap 17

Open jmanden opened this issue 4 years ago • 0 comments

Hi Mr Moroney,

Purchased your book. When running chap 17 example colab found here: https://github.com/lmoroney/tfbook/blob/master/chapter17/convert_basic.ipynb I get this error message when running the conversion:

2021-11-24 23:22:42.307496: W tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:39] Overriding allow_growth setting because the TF_FORCE_GPU_ALLOW_GROWTH environment variable is set. Original config value was 0. WARNING:tensorflow:SavedModel saved prior to TF 2.5 detected when loading Keras model. Please ensure that you are saving the model with model.save() or tf.keras.models.save_model(), NOT tf.saved_model.save(). To confirm, there should be a file named "keras_metadata.pb" in the SavedModel directory. Traceback (most recent call last):

I then use this command tf.keras.models.save_model() to save the model and it seems to work. However when I download group1-shard1of1.bin and model.json and use them with the code:

var savepar; var savepar2; async function run(){ const MODEL_URL = 'model.json'; const model = await tf.loadLayersModel(MODEL_URL); console.log(model.summary()); const input = tf.tensor2d([10.0], [1, 1]); const result = model.predict(input); alert(result); model.getWeights()[0].data().then(PromiseResult => savepar = PromiseResult[0]); model.getWeights()[1].data().then(PromiseResult => savepar2 = PromiseResult[0]); }

The savepar and savepar2 hold weights much different from ~ -1 and 2.

Do you have any suggestion as to why results are off?

Kind regards

jmanden avatar Nov 24 '21 23:11 jmanden