Complete the code to import the main PyTorch library.
import [1]
The main PyTorch library is imported using import torch.
Complete the code to create a tensor filled with zeros of size 3x3.
x = torch.[1]((3, 3))
Use torch.zeros to create a tensor filled with zeros.
Fix the error in the code to move a tensor to GPU if available.
device = torch.device('cuda' if torch.cuda.[1]() else 'cpu')
The correct method to check if CUDA is available is torch.cuda.is_available().
Fill both blanks to define a simple neural network layer using PyTorch.
layer = torch.nn.[1](in_features=10, [2]=5)
Use torch.nn.Linear for a fully connected layer. The parameter out_features defines the output size.
Fill both blanks to create a dictionary comprehension that maps layer names to their output sizes if size is greater than 5.
layer_sizes = {name: size for name, size in layers.items() if size [1] [2]The comprehension filters layers with size greater than 5 using size > 5.
