首页
随机
最近更改
特殊页面
社群首页
参数设置
关于WHY42
免责声明
WHY42
搜索
用户菜单
登录
欢迎来到Riguz的小站!这是一个私人wiki,用来记录一些我的笔记。
查看“︁PyTorch get started”︁的源代码
←
PyTorch get started
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
= Installation = == Conda Installation== <syntaxhighlight lang="bash"> conda create --name deeplearning python=3.11 conda activate deeplearning python --version // 3.11.5 </syntaxhighlight> == Install pytorch == <syntaxhighlight lang="bash"> conda install pytorch::pytorch torchvision torchaudio -c pytorch </syntaxhighlight> To verify: <syntaxhighlight lang="python"> import torch x = torch.rand(5, 3) print(x) </syntaxhighlight> Output: <syntaxhighlight lang="bash"> tensor([[0.2162, 0.2653, 0.6725], [0.5371, 0.4180, 0.1353], [0.3697, 0.5238, 0.0332], [0.6179, 0.5008, 0.9435], [0.1182, 0.3233, 0.9071]]) </syntaxhighlight> = Concepts = == Tensor(张量) == Tensors are a specialized data structure that are very similar to arrays and matrices. In PyTorch, we use tensors to encode the inputs and outputs of a model, as well as the model’s parameters. Tensors are similar to NumPy’s ndarrays, except that : * tensors can run on GPUs or other hardware accelerators * tensors are also optimized for automatic differentiation(自动微分) <syntaxhighlight lang="python"> >>> import torch >>> x = torch.arange(10) >>> x tensor([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> x.shape torch.Size([10]) >>> x.numel() 10 >>> X = x.reshape(3,4) Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: shape '[3, 4]' is invalid for input of size 10 >>> X = x.reshape(2,5) >>> X tensor([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) </syntaxhighlight> [[Category:Deep Learning]] [[Category:PyTorch]]
返回
PyTorch get started
。