optim/onn/optimizer_base.py

19 lines
314 B
Python
Raw Normal View History

2018-01-21 14:04:25 -08:00
import numpy as np
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)