codekansas/keras-language-modeling

An error when saving model and weights!

Imorton-zd opened this issue · 1 comments

json_string = tweet_model.to_json()
open(r'models\tweet_model_architecture.json', 'w', encoding = 'utf-8').write(json_string)
tweet_model.save_weights(r'models\tweet_model_weights.h5',overwrite = True)


  File "C:\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 699, in runfile
    execfile(filename, namespace)

  File "C:\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 74, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "E:/EMNLP/attention/keras-language-modeling-master/keras-language-modeling-master/tweet_similarity.py", line 305, in <module>
    json_string = tweet_model.to_json()

  File "C:\Anaconda2\lib\site-packages\keras\engine\topology.py", line 2343, in to_json
    return json.dumps(model_config, default=get_json_type, **kwargs)

  File "C:\Anaconda2\lib\json\__init__.py", line 251, in dumps
    sort_keys=sort_keys, **kw).encode(obj)

  File "C:\Anaconda2\lib\json\encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)

  File "C:\Anaconda2\lib\json\encoder.py", line 270, in iterencode
    return _iterencode(o, 0)

UnicodeDecodeError: 'utf8' codec can't decode byte 0x88 in position 22: invalid start byte

Have you met this error?

It seems like there's an encoding issue with the dataset. Maybe [this] answer on StackOverflow helps?