Surya92
(Surya Mannavan)
1
I got the below error while using pytorch. How to rectify this error? Is something wrong with the installation?
print(torch.version)
Traceback (most recent call last):
File “”, line 1, in
print(torch.version)
AttributeError: module ‘torch’ has no attribute ‘version’
a=torch.tensor([10,10,10])
a
Out[8]: tensor([10, 10, 10])
a.mean()
Traceback (most recent call last):
File “”, line 1, in
a.mean()
RuntimeError: Can only calculate the mean of floating types. Got Long instead.
1 Like
Eta_C
2
import torch
print(torch.__version__)
a = torch.tensor([10, 10, 10]) # type: Long
print(a.float().mean())
b = torch.tensor([10., 10., 10.]) # type: Float
print(a.mean())
Eta_C
3
Use __version__
insteal of _version_
.
Double underline.
Surya92
(Surya Mannavan)
4
Thanks for your response. Is it possible to calculate mean for Long data type without converting to Float?
1 Like