blade:

KeyError: ‘weight’


This is expected. If you want plain Tensors instead of Parameters, then they won’t be registered as parameters anymore (and so won’t be in _parameters).
But accessing the field on your Module will work as you expect and you will be able to differentiate through it.

AttributeError: ‘generator’ object has no attribute ‘items’

Ho that’s an oversight on our end.
Could you open an issue on github asking to add support for generator object on that API please?
As a workaround, you can use dict(model.named_parameters()) to make an actual dict from the generator.