After looking into it further, the weights for the first layer of the model are completely different between the two which would explain the different results. The input image tensor is consistent between both, meaning the problem should lie with the weights.
Here is a link to a comparison of the same layer's weights in TFJS and Keras...
I set the output of my Express HTTP file server to verbose to check whether all of the weight files were being fetched, and I noticed that they were all being fetched, but in an unsequential order, like this:
GET /model.json 200 91907 - 5.775 ms
GET /group1-shard20of20.bin 200 3770536 - 32.726 ms
GET /group1-shard3of20.bin 200 4194304 - 26.487 ms
GET /group1-shard1of20.bin 200 4194304 - 26.892 ms
GET /group1-shard7of20.bin 200 4194304 - 26.408 ms
GET /group1-shard13of20.bin 200 4194304 - 24.671 ms
GET /group1-shard10of20.bin 200 4194304 - 24.925 ms
GET /group1-shard15of20.bin 200 4194304 - 24.931 ms
GET /group1-shard5of20.bin 200 4194304 - 24.827 ms
GET /group1-shard2of20.bin 200 4194304 - 25.037 ms
GET /group1-shard6of20.bin 200 4194304 - 24.942 ms
GET /group1-shard18of20.bin 200 4194304 - 24.893 ms
GET /group1-shard16of20.bin 200 4194304 - 25.468 ms
GET /group1-shard9of20.bin 200 4194304 - 25.111 ms
GET /group1-shard11of20.bin 200 4194304 - 25.136 ms
GET /group1-shard12of20.bin 200 4194304 - 26.097 ms
GET /group1-shard8of20.bin 200 4194304 - 23.290 ms
GET /group1-shard4of20.bin 200 4194304 - 26.133 ms
GET /group1-shard14of20.bin 200 4194304 - 27.097 ms
GET /group1-shard17of20.bin 200 4194304 - 26.265 ms
GET /group1-shard19of20.bin 200 4194304 - 33.396 ms
It seems to fetch the weight files in a different order each time it is executed. Does anyone know if this is expected behaviour with the tf.loadLayersModel function? Could my weights be out of order?
I noticed some issues like this arose almost a year ago, but the bug was identified and an update to Tensorflow solved it for these people.
I am using Tensorflow JS 1.2.11 to load the model on a Node JS v10.16.3 server, and I used Tensorflow 1.14 under Python 3.7 to convert the model. I used tfjs.converters.save_keras_model() to convert the model from Keras to TFJS, and I am using this code to get the model from the HTTP server:
model = await tf.loadLayersModel('http://127.0.0.1:3001/model.json');
Thanks for your time, and please let me know if any more information is needed,
Josh
--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/6c53de9e-d7b0-437a-8bd9-7bbc325b3277%40tensorflow.org.
To unsubscribe from this group and stop receiving emails from it, send an email to tf...@tensorflow.org.