# -*- coding: utf-8 -*-
from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)
x = torch.zeros(5, 3, dtype=torch.long)
print(x)
x = torch.tensor([5.5, 3])
print(x)
x = x.new_ones(5, 3, dtype=torch.double)
# new_* methods take in sizes
print(x)
x = torch.randn_like(x, dtype=torch.float)
# override dtype!
print(x)
# result has the same size
print(x.size())
y = torch.rand(5, 3)
print(x + y)
print(torch.add(x, y))
result = torch.empty(5, 3)
torch.add(x, y, out=result)
print("result:\n", result)
# add: in-place
# adds x to y
y.add_(x)
print("y:\n", y)
print(x[:, 1])
# 改变tensor大小或形状
x = torch.randn(4, 4)
y = x.view(16)
z = x.view(