Dispatch optimizers
Created by: gcarleo
Here I am also dispatching optimizers automatically. This introduces an important breaking change:
all optimizers (including Sgd, SR etc) now need to be constructed with a first positional argument (the machine).
It is not so nice to break the interface we had in 2.0, but somehow it was also a conceptual issue not to have machine as an argument to the optimizers (for example in SR we had to inizialize it by hand afterwards, with an explicit machine, and that was error prone).
The only very annoying thing is that functools.singledispatch
works only with positional arguments, thus
nk.optimizer.Sgd(machine=ma,learning_rate=0.01)
wouldn't work, one needs to do
nk.optimizer.Sgd(ma,learning_rate=0.01)
Any idea on how to solve this?
close #413 (closed)