Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

python - TypeError: Cannot interpret 'torch.uint8' as a data type

Today I have started to learn Pytorch and I stuck here. The code piece in the comment raises this error: TypeError: Cannot interpret 'torch.uint8' as a data type

For changing the data type of the tensor I used: quzu_torch = quzu_torch.type(torch.float) But this time I got this error: TypeError: Cannot interpret 'torch.float32' as a data type

import numpy as np
import torch
from matplotlib import pyplot as plt

quzu = np.array(Image.open('wool.jpg').resize((224,224)))

quzu_torch = torch.from_numpy(quzu)

plt.imsave('quzucuq.jpg', quzu)

# quzu_torch = quzu_torch.type(torch.bool)
plt.imsave('quzucuq_tensor.jpg', quzu_torch)```
question from:https://stackoverflow.com/questions/65886274/typeerror-cannot-interpret-torch-uint8-as-a-data-type

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...