2018-01-21 14:04:25 -08:00
|
|
|
import numpy as np
|
|
|
|
|
2018-03-17 06:09:15 -07:00
|
|
|
from .float import _f
|
2018-01-21 14:04:25 -08:00
|
|
|
|
2018-01-22 11:40:36 -08:00
|
|
|
|
2018-01-21 14:04:25 -08:00
|
|
|
class Optimizer:
|
|
|
|
def __init__(self, lr=0.1):
|
2018-01-22 11:40:36 -08:00
|
|
|
self.lr = _f(lr) # learning rate
|
2018-01-21 14:04:25 -08:00
|
|
|
self.reset()
|
|
|
|
|
|
|
|
def reset(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def compute(self, dW, W):
|
|
|
|
return -self.lr * dW
|
|
|
|
|
|
|
|
def update(self, dW, W):
|
|
|
|
W += self.compute(dW, W)
|