Hi Tianle!



 tianle-BigRice:

TypeError: optimizer can only optimize Tensors, but one of the params is list

        params = []
...
        print(type(params))
        if opt.use_adam:
            self.optimizer = t.optim.Adam([params, {'params': self.awl.parameters(), 'weight_decay': 0}])



Your problem is that you passing your optimizer a list that consists
of a list and a dict.  Quoting from the torch.optim 8 documentation:

Per-parameter options
Optimizer 6 s also support specifying per-parameter options. To do this, instead of passing an iterable of Variable s, pass in an iterable of dict 3 s. Each of them will define a separate parameter group, and should contain a params key, containing a list of parameters belonging to it.

(Note, this documentation should be updated to reflect that Variable
is deprecated; the term Parameter should be used instead.)
That is, you can pass in  a list of Parameters or a list of dicts
(that contain lists of Parameters), but you can’t pass in a list
of lists.
I think this would work for you:
        print(type(params))   # at this point params is a list of dicts
        if opt.use_adam:
            params += [{'params': self.awl.parameters(), 'weight_decay': 0}]
            self.optimizer = t.optim.Adam (params)   # still a list of dicts

Best.
K. Frank