2025 USA-NA-AIO Round 2, Problem 1, Part 6

Part 6 (10 points, coding task)

In this part, you are asked to create the dataset \mathcal D_{IC}.

  1. Define dataset \mathcal D_{IC} in the way that for each \left( t, x \right) \in \mathcal D_{IC}, t is fixed at 0 and x is evenly sampled from \left\{ 0, 0.01, 0.02, \cdots , 0.98, 0.99, 1 \right\}. Therefore, | \mathcal D_{IC} | = 101.

  2. The dataset shall be a tensor with name dataset_train_IC and shape (101,2).

  3. Set dataset_train_IC.requires_grad = True.

  4. Print dataset_train_IC.requires_grad and dataset_train_IC.shape.

  5. Define tensor u_IC to be the groud-truth functional values of all data in \mathcal D_{IC} (You can find the formula from Part 1).

  6. Set u_IC.requires_grad = True and u_IC.shape = (101,1).

  7. Print u_IC.requires_grad and u_IC.shape.

### WRITE YOUR SOLUTION HERE ###

num_samples = 101

dataset_train_IC = torch.stack([torch.zeros(num_samples), torch.linspace(0, 1, num_samples)], dim=1)

print(dataset_train_IC.requires_grad)
print(dataset_train_IC.shape)

u_IC = torch.sin(torch.pi * dataset_train_IC[:,1].view(-1,1))
u_IC.requires_grad_(True)

print(u_IC.requires_grad)
print(u_IC.shape)

""" END OF THIS PART """