Different prediction of Tensorflow in Python and C-API with SavedModel

I trained and tested a model in python with Keras and save it in SavedModel format. Then I imported it with the C-API and TF_LoadSessionFromSavedModel(). I predict the same set of data in python and C but get different results. The predictions in python are ok, the predictions in C are not ok, but also not fully nonsense.

Things I have checked:

  • Tensorflow Version 2.5 in Python and C
  • use of the same model
  • use of the same data with same format
  • load the SavedModel in Python again
  • try different arcitectures
  • train without keras in low-level tensorflow

Every time python results are good, C results are different and worse.

Is there something wrong with the SavedModel Format regarding Python and C?

Ore any other tipps to solve this problem?


Solution 1:

The Problem was, that the dataset was normalized in python as type float64 and in C as type float32.

Same type with same normalization gives the same result. Thanks @GPhilo for your comment. It was the right direction!