sherjilozair / char-rnn-tensorflow

Multi-layer Recurrent Neural Networks (LSTM, RNN) for character-level language models in Python using Tensorflow
MIT License
2.64k stars 960 forks source link

Encode output #78

Closed hugovk closed 7 years ago

hugovk commented 7 years ago

When the output contains Unicode like ä and ö, and redirecting output like python sample.py > output.txt

Traceback (most recent call last):
  File "sample.py", line 44, in <module>
    main()
  File "sample.py", line 27, in main
    sample(args)
  File "sample.py", line 41, in sample
    print(model.sample(sess, chars, vocab, args.n, args.prime, args.sample))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 31: ordinal not in range(128)

So encode the output as UTF-8 instead.

hugovk commented 7 years ago

@sherjilozair Is this okay to merge, or would you like some updates?

ubergarm commented 7 years ago

Ahh, you already did this too, sorry i'm working backwards in time! This could help the builds issue.

ubergarm commented 7 years ago

Thanks, utf-8 is the right way to go.