-2

I am using PyTorch with python3. I tried the following while in ipdb mode:

regions = np.zeros([107,4], dtype='uint8')
torch.from_numpy(regions)

This prints the tensor. However when trying:

regions = np.zeros([107,107,4], dtype='uint8')
torch.from_numpy(regions)

I get the following error:

*** UnicodeEncodeError: 'ascii' codec can't encode character '\u22ee' in position 72: ordinal not in range(128)

I'm am using:

numpy==1.11.3
torch==0.2.0.post4
torchvision==0.1.9

and python3.5.3

2

2 Answers 2

0

I'm able to run both versions of your code with no issues in a jupyter notebook. I'm gonna say that this kind of Unicode codec error is not due to .from_numpy()

I'm running Python 3.5.2 |Anaconda custom (x86_64)

numpy==1.13.0
torch==0.1.12.post2
torchvision==0.1.8
Sign up to request clarification or add additional context in comments.

Comments

0

From the website http://pytorch.org/ they say:

Please ensure that you are on the latest pip and numpy packages.

I was not able to reproduce your errors with recent versions of numpy and pytorch. I think pip install -U numpy might solve the problem.

1 Comment

I have a similar problem trying github.com/jojonki/BiDAF I did what you suggest and I'm still having the same problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.