torch item

This commit is contained in:
2020-10-30 19:25:38 +01:00
parent dcbedfe237
commit 8f0850997c
+11 -4
View File
@@ -21,7 +21,14 @@ import torch
# print(x[:, 1])
x = torch.randn(4, 4)
y = x.view(16)
z = x.view(-1, 8) # the size -1 is inferred from other dimensions
print(x.size(), y.size(), z.size())
# x = torch.randn(4, 4)
# y = x.view(16)
# z = x.view(-1, 8) # the size -1 is inferred from other dimensions
# print(x.size(), y.size(), z.size())
x = torch.randn(1)
print(x)
print(x.item())
a = torch.ones(5)
print(a)