️️ ️️ ️️ ️️ ️️

PyTorch

PyTorch Gist

image

python3 -m venv pytorch-env
source pytorch-env/bin/activate

PyTorch Installation:

image

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
>>> import torch
>>> print(torch.__version__)
2.6.0+cu118

#creating 3 dimensional tensor with four values

>>> print(torch.rand(3,4))
tensor([[0.7422, 0.2962, 0.2246, 0.3841],
        [0.7613, 0.2975, 0.6477, 0.5489],
        [0.4998, 0.1768, 0.4745, 0.8000]])

#check if GPU is available

>>> torch.cuda.is_available()
True

all tags