[docs]@torch.no_grad()defstep(self,closure=None):"""Performs a single optimization step. Args: closure (callable, optional): A closure that reevaluates the model and returns the loss. """loss=NoneifclosureisnotNone:withtorch.enable_grad():loss=closure()forgroupinself.param_groups:params_with_grad=[]grads=[]state_sums=[]state_steps=[]forpingroup['params']:ifp.gradisnotNone:params_with_grad.append(p)grads.append(p.grad)state=self.state[p]state_sums.append(state['sum'])# update the steps for each param group updatestate['step']+=1# record the step after step updatestate_steps.append(state['step'])F.adagrad(params_with_grad,grads,state_sums,state_steps,lr=group['lr'],weight_decay=group['weight_decay'],lr_decay=group['lr_decay'],eps=group['eps'])returnloss
Docs
Access comprehensive developer documentation for PyTorch
To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.