netket.errors.ForwardAndBackwardDeprecationWarning#
- exception netket.errors.ForwardAndBackwardDeprecationWarning[source]#
Warning issued when a driver subclass overrides the deprecated
_forward_and_backwardmethod instead of the renamedcompute_loss_and_update.The method
_forward_and_backwardhas been renamed tocompute_loss_and_updatein the new driver base class. The two methods differ in their return value: the old one returned only the gradient (settingself._loss_statsas a side-effect), while the new one must return a(loss_stats, gradient)tuple.NetKet will automatically wrap your old implementation so that it is compatible with the new interface, but you should update your code to silence this warning.
Examples
Instead of:
class MyDriver(nk.driver.AbstractOptimizationDriver): def _forward_and_backward(self): # ... compute loss and gradient ... self._loss_stats = loss return gradient
Use:
class MyDriver(nk.driver.AbstractOptimizationDriver): def compute_loss_and_update(self): # ... compute loss and gradient ... return loss, gradient