
PyTorch是Facebook发布的一款非常具有个性的深度学习框架,它和Tensorflow,Keras,Theano等其他深度学习框架都不同,它是动态计算图模式,其应用模型支持在运行过程中根据运行参数动态改变,而其他几种框架都是静态计算图模式,其模型在运行之前就已经确定。
pip install numpy
pip install scipy
pip install http://download.pytorch.org/whl/cu75/torch-0.1.12.post2-cp27-none-linux_x86_64.whl
import torch
x = torch.Tensor(5,3)
x = torch.empty(5, 3) #创建一个未经初始化的Tensor
x = torch.rand(5, 3) #创建一个随机初始化的Tensor
x = torch.zeros(5, 3, dtype=torch.long) #创建一个全零的Tensor
x = x.new_ones(5, 3, dtype=torch.float64) # 返回的tensor默认具有相同的torch.dtype和torch.device
x = torch.randn_like(x, dtype=torch.float) # 指定新的数据类型
print("x Tensor: ",x)
import torch
x = torch.rand(5, 3)
y = torch.rand(5, 3)
result = torch.empty(5, 3)
result