0

I am facing the age old problem of UnicodeDecodeError while reading a json file.

I store the file:

model_json = model.to_json()

with open("trainedModel_-4_15.json", "w") as json_file:
    json_file.write(model_json)

And read it by:

json_file = open('trainedModel_-4_15.json', 'rb')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json, {"tf":tf})

I have tried various methods mentioned on the net but all in vain.

yamini goel
  • 519
  • 2
  • 10
  • 23
  • Possible duplicate of [Unicode (UTF-8) reading and writing to files in Python](https://stackoverflow.com/questions/491921/unicode-utf-8-reading-and-writing-to-files-in-python). The question is a bit long-winded but it is essentially the same and the answers apply to this question. – Tom Blodget Mar 25 '19 at 16:19
  • 1
    @TomBlodget I have tried most of the methods mentioned in the question you suggested but the problem still persists. I am storing and reading a Keras model...is there something exclusively for models trained in Keras? – yamini goel Mar 26 '19 at 03:52

0 Answers0