I have a module that stores a list of nn.Parameter
s (old gradients - it’s an optimizer).
I only store a fixed number, say 100, so after a while I want to kick out the oldest.
My natural instinct is to use a python deque
, but of course that won’t work, since I need to store my parameters in a ParameterList
or ParameterDict
for stuff like .cuda()
or .double()
to work.
Now I wonder if I should just bite the (perhaps not that great) performance bullet of using a ParameterList
as a deque, just calling del list[0]
at each step.
Or if I should clone nn.ParameterList
and make my own implementation using deque
?
I suppose I could also use a ParameterDict
with consecutive integers as keys…
None of the options seem ideal. Is there a best practice I should refer to?