# Path: dsenser/theano_utils.py
# def floatX(a_data, a_dtype=config.floatX):
#     """Return numpy array populated with the given data.
# 
#     Args:
#       data (np.array):
#         input tensor
#       dtype (class):
#         digit type
# 
#     Returns:
#       np.array:
#         array populated with the given data
# 
#     """
#     return np.asarray(a_data, dtype=a_dtype)
# 
# def rmsprop(tparams, grads, x, y, cost):
#     """A variant of SGD that automatically scales the step size.
# 
#     Args:
#       tpramas (Theano SharedVariable):
#           Model parameters
#       grads (Theano variable):
#           Gradients of cost w.r.t to parameres
#       x (list):
#           Model inputs
#       y (Theano variable):
#           Targets
#       cost (Theano variable):
#           Objective fucntion to minimize
# 
#     Notes:
#       For more information, see [Hint2014]_.
# 
#     .. [Hint2014] Geoff Hinton, *Neural Networks for Machine Learning*,
#        lecture 6a,
#        http://cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf
# 
#     """
#     zipped_grads = [theano.shared(p.get_value() * floatX(0.))
#                     for p in tparams]
#     running_grads = [theano.shared(p.get_value() * floatX(0.))
#                      for p in tparams]
#     running_grads2 = [theano.shared(p.get_value() * floatX(0.))
#                       for p in tparams]
# 
#     zgup = [(zg, g) for zg, g in zip(zipped_grads, grads)]
#     rgup = [(rg, 0.95 * rg + 0.05 * g) for rg, g in zip(running_grads, grads)]
#     rg2up = [(rg2, 0.95 * rg2 + 0.05 * (g ** 2))
#              for rg2, g in zip(running_grads2, grads)]
# 
#     f_grad_shared = theano.function(x + [y], cost,
#                                     updates=zgup + rgup + rg2up,
#                                     name='rmsprop_f_grad_shared')
#     updir = [theano.shared(p.get_value() * floatX(0.))
#              for p in tparams]
#     updir_new = [(ud, 0.9 * ud - 1e-4 * zg / TT.sqrt(rg2 - rg ** 2 + 1e-4))
#                  for ud, zg, rg, rg2 in zip(updir, zipped_grads, running_grads,
#                                             running_grads2)]
#     param_up = [(p, p + udn[1])
#                 for p, udn in zip(tparams, updir_new)]
#     f_update = theano.function([], [], updates=updir_new + param_up,
#                                on_unused_input='ignore',
#                                name='rmsprop_f_update')
#     params = [zipped_grads, running_grads, running_grads2, updir]
#     return (f_grad_shared, f_update, params)
# 
# CONV_EPS = 1e-5
# 
# HE_UNIFORM = lambda x: floatX(_HE_UNIFORM.sample(x))
# 
# MAX_ITERS = 150  # 450


from dsenser.theano_utils import floatX, rmsprop, \
    CONV_EPS, HE_UNIFORM, MAX_ITERS
from datetime import datetime
from lasagne.init import HeUniform, Orthogonal
from theano import config, tensor as TT
import numpy as np
import sys
import theano

    def predict(self, a_x):
        """Method for predicting sense of single relation.

        Args:
        a_x (np.array):
          (submodels x class) array of input predictions

        Returns:
        str:
          most probable sense of discourse relation

        """
        return self._predict(a_x)

    def _init_X2Y(self):
        """Initialize tensor for mapping input mtx to output vec.

        Args:
        (void)

        Returns:
        (theano.shared):
          shared theano tensor

        """
        tens = np.zeros((self.n_y, self.n_x, self.n_y))
        tens -= EPS
        for i in xrange(self.n_y):
            tens[i, :, i] = 1.

# Path: dsenser/theano_utils.py
# def floatX(a_data, a_dtype=config.floatX):
#     """Return numpy array populated with the given data.
# 
#     Args:
#       data (np.array):
#         input tensor
#       dtype (class):
#         digit type
# 
#     Returns:
#       np.array:
#         array populated with the given data
# 
#     """
#     return np.asarray(a_data, dtype=a_dtype)
# 
# def rmsprop(tparams, grads, x, y, cost):
#     """A variant of SGD that automatically scales the step size.
# 
#     Args:
#       tpramas (Theano SharedVariable):
#           Model parameters
#       grads (Theano variable):
#           Gradients of cost w.r.t to parameres
#       x (list):
#           Model inputs
#       y (Theano variable):
#           Targets
#       cost (Theano variable):
#           Objective fucntion to minimize
# 
#     Notes:
#       For more information, see [Hint2014]_.
# 
#     .. [Hint2014] Geoff Hinton, *Neural Networks for Machine Learning*,
#        lecture 6a,
#        http://cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf
# 
#     """
#     zipped_grads = [theano.shared(p.get_value() * floatX(0.))
#                     for p in tparams]
#     running_grads = [theano.shared(p.get_value() * floatX(0.))
#                      for p in tparams]
#     running_grads2 = [theano.shared(p.get_value() * floatX(0.))
#                       for p in tparams]
# 
#     zgup = [(zg, g) for zg, g in zip(zipped_grads, grads)]
#     rgup = [(rg, 0.95 * rg + 0.05 * g) for rg, g in zip(running_grads, grads)]
#     rg2up = [(rg2, 0.95 * rg2 + 0.05 * (g ** 2))
#              for rg2, g in zip(running_grads2, grads)]
# 
#     f_grad_shared = theano.function(x + [y], cost,
#                                     updates=zgup + rgup + rg2up,
#                                     name='rmsprop_f_grad_shared')
#     updir = [theano.shared(p.get_value() * floatX(0.))
#              for p in tparams]
#     updir_new = [(ud, 0.9 * ud - 1e-4 * zg / TT.sqrt(rg2 - rg ** 2 + 1e-4))
#                  for ud, zg, rg, rg2 in zip(updir, zipped_grads, running_grads,
#                                             running_grads2)]
#     param_up = [(p, p + udn[1])
#                 for p, udn in zip(tparams, updir_new)]
#     f_update = theano.function([], [], updates=updir_new + param_up,
#                                on_unused_input='ignore',
#                                name='rmsprop_f_update')
#     params = [zipped_grads, running_grads, running_grads2, updir]
#     return (f_grad_shared, f_update, params)
# 
# CONV_EPS = 1e-5
# 
# HE_UNIFORM = lambda x: floatX(_HE_UNIFORM.sample(x))
# 
# MAX_ITERS = 150  # 450


# Path: dsenser/judge/base.py
from dsenser.theano_utils import floatX, rmsprop, \
    CONV_EPS, HE_UNIFORM, MAX_ITERS
from datetime import datetime
from lasagne.init import HeUniform, Orthogonal
from theano import config, tensor as TT
import numpy as np
import sys
import theano


    def predict(self, a_x):
        """Method for predicting sense of single relation.

        Args:
        a_x (np.array):
          (submodels x class) array of input predictions

        Returns:
        str:
          most probable sense of discourse relation

        """
        return self._predict(a_x)

    def _init_X2Y(self):
        """Initialize tensor for mapping input mtx to output vec.

        Args:
        (void)

        Returns:
        (theano.shared):
          shared theano tensor

        """
        tens = np.zeros((self.n_y, self.n_x, self.n_y))
        tens -= EPS
        for i in xrange(self.n_y):
            tens[i, :, i] = 1.

        return theano.shared(value=floatX(tens),