I have some model in pytorch, whose updatable weights I want to access and change manually.
How would that be done correctly?
Ideally, I would like a tensor of those weights.
It seems to me that
for parameter in model.parameters():
do_something_to_parameter(parameter)
wouldn't be the right way to go, because
- It doesn't utilize GPU, and is not able to
- It doesn't even utilize low level implementation
What is the correct way of accessing a model's weights manually (not through loss.backward
and optimizer.step
)?