def grad_fn(self, theta, xt): old_params = get_flat_params(self) set_flat_params(self, theta) grad = self.grad(xt) set_flat_params(old_params) return grad
def add_to_params(self, grad): params = get_flat_params(self) set_flat_params(self, params + grad)
def pred_fn(self, theta, xt): old_params = get_flat_params(self) set_flat_params(self, theta) v = self.predict(xt) set_flat_params(old_params) return v
def get_params(self): return get_flat_params(self)