mirror of
https://github.com/fastai/fastbook.git
synced 2025-04-07 19:30:43 +00:00
Merge de5bf73aa4
into e8baa81d89
This commit is contained in:
commit
fbab48042d
@ -4825,10 +4825,10 @@
|
|||||||
"class BasicOptim:\n",
|
"class BasicOptim:\n",
|
||||||
" def __init__(self,params,lr): self.params,self.lr = list(params),lr\n",
|
" def __init__(self,params,lr): self.params,self.lr = list(params),lr\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def step(self, *args, **kwargs):\n",
|
" def step(self):\n",
|
||||||
" for p in self.params: p.data -= p.grad.data * self.lr\n",
|
" for p in self.params: p.data -= p.grad.data * self.lr\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def zero_grad(self, *args, **kwargs):\n",
|
" def zero_grad(self):\n",
|
||||||
" for p in self.params: p.grad = None"
|
" for p in self.params: p.grad = None"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user