PyTorch: Difference between revisions

 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:


==Installation==
==Installation==
See [https://pytorch.org/get-started/locally/ PyTorch Getting Started]
See [https://pytorch.org/get-started/locally/ PyTorch Getting Started] and [https://pytorch.org/get-started/previous-versions/ PyTorch Previous Versions]
<syntaxhighlight lang="bash">


# If using conda, python 3.5+, and CUDA 10.0 (+ compatible cudnn)
I recommend using the conda installation method since it is paired with the correct version of cuda.
conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
</syntaxhighlight>


==Getting Started==
==Getting Started==
Line 45: Line 42:


==Usage==
==Usage==
Note that there are some useful functions under <code>torch.nn.functional</code> which is typically imported as <code>F</code>.
Note that there are several useful functions under <code>torch.nn.functional</code> which is typically imported as <code>F</code>.
Most neural network layers are actually implemented in functional.


===torch.meshgrid===
===torch.meshgrid===
Line 79: Line 77:
See [https://pytorch.org/tutorials/beginner/former_torchies/parallelism_tutorial.html Multi-GPU Examples].
See [https://pytorch.org/tutorials/beginner/former_torchies/parallelism_tutorial.html Multi-GPU Examples].


==nn.DataParallel==
===nn.DataParallel===


The basic idea is to wrap blocks in [https://pytorch.org/docs/stable/generated/torch.nn.DataParallel.html#torch.nn.DataParallel <code>nn.DataParallel</code>].   
The basic idea is to wrap blocks in [https://pytorch.org/docs/stable/generated/torch.nn.DataParallel.html#torch.nn.DataParallel <code>nn.DataParallel</code>].