# Path: imagernn/utils.py
# def numpy_floatX(data):
#     return np.asarray(data, dtype=config.floatX)


import time
import numpy as np
import theano
import theano.tensor as tensor
from imagernn.utils import numpy_floatX
    f_grad_accum = theano.function(inp_list, cost,
                                    updates= agup,
                                    name='rmsprop_f_grad_shared')
    f_accumgrad_clr = theano.function([], [],updates=agclear, name='accum_grad_clr')
    
    return f_grad_accum, f_accumgrad_clr, accum_grads

# ========================================================================================
  def rmsprop(self, lr, tparams, grads, inp_list, cost, params):
    clip = params['grad_clip']
    decay_rate = tensor.constant(params['decay_rate'], dtype=theano.config.floatX) 
    smooth_eps = tensor.constant(params['smooth_eps'], dtype=theano.config.floatX)
    zipped_grads = [theano.shared(np.zeros_like(p.get_value()),
                                  name='%s_grad' % k)
                    for k, p in tparams.iteritems()]
    running_grads2 = [theano.shared(np.zeros_like(p.get_value()),
                                    name='%s_rgrad2' % k)
                      for k, p in tparams.iteritems()]
    zgup = [(zg, g) for zg, g in zip(zipped_grads, grads)]
    if clip > 0.0:
        rg2up = [(rg2, tensor.clip(decay_rate * rg2 + (1 - decay_rate) * (tensor.clip(g,-clip,clip) ** 2),0.0,np.inf))
             for rg2, g in zip(running_grads2, grads)]
    else:
        rg2up = [(rg2, tensor.clip(decay_rate * rg2 + (1 - decay_rate) * (g ** 2),0.0,np.inf))
             for rg2, g in zip(running_grads2, grads)]
  
    f_grad_shared = theano.function(inp_list, cost,
                                    updates=zgup + rg2up,
                                    name='rmsprop_f_grad_shared')


# Path: imagernn/utils.py
# def numpy_floatX(data):
#     return np.asarray(data, dtype=config.floatX)


# Path: imagernn/solver.py
import time
import numpy as np
import theano
import theano.tensor as tensor
from imagernn.utils import numpy_floatX

    f_grad_accum = theano.function(inp_list, cost,
                                    updates= agup,
                                    name='rmsprop_f_grad_shared')
    f_accumgrad_clr = theano.function([], [],updates=agclear, name='accum_grad_clr')
    
    return f_grad_accum, f_accumgrad_clr, accum_grads

# ========================================================================================
  def rmsprop(self, lr, tparams, grads, inp_list, cost, params):
    clip = params['grad_clip']
    decay_rate = tensor.constant(params['decay_rate'], dtype=theano.config.floatX) 
    smooth_eps = tensor.constant(params['smooth_eps'], dtype=theano.config.floatX)
    zipped_grads = [theano.shared(np.zeros_like(p.get_value()),
                                  name='%s_grad' % k)
                    for k, p in tparams.iteritems()]
    running_grads2 = [theano.shared(np.zeros_like(p.get_value()),
                                    name='%s_rgrad2' % k)
                      for k, p in tparams.iteritems()]
    zgup = [(zg, g) for zg, g in zip(zipped_grads, grads)]
    if clip > 0.0:
        rg2up = [(rg2, tensor.clip(decay_rate * rg2 + (1 - decay_rate) * (tensor.clip(g,-clip,clip) ** 2),0.0,np.inf))
             for rg2, g in zip(running_grads2, grads)]
    else:
        rg2up = [(rg2, tensor.clip(decay_rate * rg2 + (1 - decay_rate) * (g ** 2),0.0,np.inf))
             for rg2, g in zip(running_grads2, grads)]
  
    f_grad_shared = theano.function(inp_list, cost,
                                    updates=zgup + rg2up,
                                    name='rmsprop_f_grad_shared')


    updir = [theano.shared(p.get_value() * numpy_floatX(0.),