Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

world_language_model example throws UnicodeEncodeError #1202

Open
miebster opened this issue Dec 2, 2023 · 0 comments
Open

world_language_model example throws UnicodeEncodeError #1202

miebster opened this issue Dec 2, 2023 · 0 comments

Comments

@miebster
Copy link

miebster commented Dec 2, 2023

Your issue may already be reported!
Please search on the issue tracker before creating one.

Context

  • Python 3.11
  • Pytorch version: 2.1.1
  • Operating System and version: Windows 10 Pro, 22H2, 19045.3693

Your Environment

Expected Behavior

Following the commands in the world_language_model readme should finish without error.

Current Behavior

During generate.py, an UnicodeEncodeError is thrown when trying to write 'ზ' to the file.

Possible Solution

I resolved the issue by changing line 66 of generate.py

from:
with open(args.outf, 'w') as outf:

to:
with open(args.outf, 'w', encoding="utf-8") as outf:

Steps to Reproduce

cd .\word_language_model
python main.py --cuda --epochs 6
python generate.py

Failure Logs [if any]

| Generated 0/1000 words
| Generated 100/1000 words
| Generated 200/1000 words
| Generated 300/1000 words
| Generated 400/1000 words
| Generated 500/1000 words
Traceback (most recent call last):
File "REDACTED\word_language_model\generate.py", line 83, in
outf.write(word + ('\n' if i % 20 == 19 else ' '))
File "REDACTED\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u10d6' in position 0: character maps to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant