PyTorch Basics
GPU & CPU
Tensors
Tensor Operations
Installation & Syntax
100

What is PyTorch?

A deep learning library developed by Facebook AI

100

What is the primary function of a CPU?

Handling general-purpose tasks

100

What is a tensor in PyTorch?

A multi-dimensional array used for computations

100

What does torch.max(x) do?

 Finds the maximum value in x

100

How do you install PyTorch?

pip install torch torchvision torchaudio

200

Why is PyTorch widely used?

 It has strong GPU support and is flexible

200

Why are GPUs preferred for deep learning?

They have thousands of cores for parallel processing

200

What makes tensors efficient for deep learning?
 

They can be processed on GPUs

200

How do you concatenate tensors along rows?

torch.cat((x, y), dim=0)

200

How do you create a tensor from a list?

torch.tensor([1, 2, 3])

300

Who developed PyTorch?

 Facebook AI

300

How many cores does a typical CPU have?

A few (2–16)

300

 How do you specify a tensor’s data type?)

 torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32)

300

How do you transpose a tensor?

x.T or x.transpose(0,1)

300

How do you check if a GPU is available in PyTorch?

torch.cuda.is_available()

400

Which company manufactures GPUs for deep learning?

NVIDIA

400

How do you move a tensor to GPU?

x.to("cuda")

400

What does torch.zeros(3,3) do?

 Creates a 3×3 matrix filled with zeros

400

How do you compute the mean of a tensor?

 torch.mean(x)

400

How do you check a tensor’s data type?

print(x.dtype)

500

What is the purpose of torch.view()?

To change the tensor’s shape

500

What does torch.split(x, 2) do?

Splits x into multiple tensors

500

Which function creates a random tensor?

torch.rand(2,2)

500

How do you perform matrix multiplication?

torch.matmul(A, B) or torch.mm(A, B)

500

How do you convert a tensor to a NumPy array?

x.numpy()