# Path: mozi/utils/theano_utils.py
# def sharedX(value, dtype=floatX, name=None, borrow=False, **kwargs):
#     return theano.shared(np.asarray(value, dtype=dtype), name=name, borrow=borrow, **kwargs)
# 
# def asfloatX(X):
#     return np.asarray(X, dtype=floatX)


import theano
import theano.tensor as T
import numpy as np
from theano.ifelse import ifelse
from mozi.utils.theano_utils import sharedX, asfloatX

floatX = theano.config.floatX


class LearningMethod(object):

    def update(self, deltas, params, gparams):
        """
        Return a list of tuples
        """
        raise NotImplementedError(str(type(self))+" does not implement delta.")

    @property
    def learning_rate(self):
        return float(self.lr.get_value())

    @property
    def momentum(self):
        return float(self.mom.get_value())


class DecayLearning(LearningMethod):

    def __init__(self, lr_decay_factor=1.0, decay_batch=10000):
        self.batch = sharedX(0)
        self.decay_batch = sharedX(decay_batch)

# Path: mozi/utils/theano_utils.py
# def sharedX(value, dtype=floatX, name=None, borrow=False, **kwargs):
#     return theano.shared(np.asarray(value, dtype=dtype), name=name, borrow=borrow, **kwargs)
# 
# def asfloatX(X):
#     return np.asarray(X, dtype=floatX)


# Path: mozi/learning_method.py
import theano
import theano.tensor as T
import numpy as np
from theano.ifelse import ifelse
from mozi.utils.theano_utils import sharedX, asfloatX


floatX = theano.config.floatX


class LearningMethod(object):

    def update(self, deltas, params, gparams):
        """
        Return a list of tuples
        """
        raise NotImplementedError(str(type(self))+" does not implement delta.")

    @property
    def learning_rate(self):
        return float(self.lr.get_value())

    @property
    def momentum(self):
        return float(self.mom.get_value())


class DecayLearning(LearningMethod):

    def __init__(self, lr_decay_factor=1.0, decay_batch=10000):
        self.batch = sharedX(0)
        self.decay_batch = sharedX(decay_batch)

        self.lr_decay_factor = asfloatX(lr_decay_factor)