Thanks, @ptrblck. Sorry, I’m not used to working with scalars like this. When I change it to this:
    self.a = nn.Parameter(torch.tensor(1., requires_grad=True))
    self.b = nn.Parameter(torch.tensor(1., requires_grad=True))

I get this:
TypeError: 'Parameter' object is not callable