Premium problem73. Freeze a Backbone

Medium Locked

Build a model with two named submodules -- backbone, a Linear(4, 4), and classifier, a Linear(4, 2) -- seeding with torch.manual_seed(seed) immediately before, backbone first.

Freeze every parameter in backbone while leaving classifier trainable, then return a list of (name, requires_grad) pairs for every named parameter, in the order named_parameters() yields them.

The list is what gets graded rather than the model, because two models with identical weights are still different objects to the comparison.

Input

0

Output

[('backbone.weight', False),
 ('backbone.bias', False),
 ('classifier.weight', True),
 ('classifier.bias', True)]

Premium problem

This one's part of Premium. Unlock the full PyTorch track plus every other premium problem on the site.

Implement solve(...)