# Path: beacon8/optimizers/Optimizer.py
# class Optimizer:
# 
#     def __init__(self, **hyperparams):
#         self.states = {}
#         self.hyperparams = hyperparams
# 
#     def update_parameters(self, model):
# 
#         if model not in self.states:
#             params, grads = model.parameters()
#             # TODO: Not only scalar
#             hyperparams = {name: _T.scalar(name) for name in self.hyperparams}
#             updates = self.get_updates(params, grads, **hyperparams)
#             self.states[model] = _th.function(
#                 inputs=list(hyperparams.values()),
#                 updates=updates
#             )
# 
#         self.states[model](**self.hyperparams)
# 
#     def get_updates(self, params, grads):
#         raise NotImplementedError


from ..optimizers import Optimizer


class SGD(Optimizer):

    def __init__(self, lr):
        Optimizer.__init__(self, lr=lr)

    def get_updates(self, params, grads, lr):

# Path: beacon8/optimizers/Optimizer.py
# class Optimizer:
# 
#     def __init__(self, **hyperparams):
#         self.states = {}
#         self.hyperparams = hyperparams
# 
#     def update_parameters(self, model):
# 
#         if model not in self.states:
#             params, grads = model.parameters()
#             # TODO: Not only scalar
#             hyperparams = {name: _T.scalar(name) for name in self.hyperparams}
#             updates = self.get_updates(params, grads, **hyperparams)
#             self.states[model] = _th.function(
#                 inputs=list(hyperparams.values()),
#                 updates=updates
#             )
# 
#         self.states[model](**self.hyperparams)
# 
#     def get_updates(self, params, grads):
#         raise NotImplementedError


# Path: beacon8/optimizers/SGD.py
from ..optimizers import Optimizer



class SGD(Optimizer):

    def __init__(self, lr):
        Optimizer.__init__(self, lr=lr)

    def get_updates(self, params, grads, lr):

        return [(p, p - lr * g) for p, g in zip(params, grads)]