# Path: seya/utils.py
# def diff_abs(z):
#     return T.sqrt(T.sqr(z)+1e-6)
# 
# def theano_rng(seed=123):
#     return MRG_RandomStreams(seed=seed)


import theano
import theano.tensor as T
import numpy as np
from theano.tensor.signal.downsample import max_pool_2d
from keras.layers.core import Layer
from keras.layers.recurrent import Recurrent
from keras import activations, initializations
from keras.utils.theano_utils import alloc_zeros_matrix, sharedX
from keras.layers.convolutional import conv_output_length
from ..utils import diff_abs, theano_rng
        self.truncate_gradient = truncate_gradient
        self.activation = lambda x: .5*(1 + T.exp(-x))
        self.input = T.matrix()

        self.W = self.init((self.output_dim, self.input_dim))
        self.trainable_weights = [self.W]

        self.regularizers = []
        if W_regularizer:
            W_regularizer.set_param(self.W)
            self.regularizers.append(W_regularizer)
        if activity_regularizer:
            activity_regularizer.set_layer(self)
            self.regularizers.append(activity_regularizer)
        kwargs['input_shape'] = (None, self.input_dim)
        super(VarianceCoding, self).__init__(**kwargs)

    @property
    def output_shape(self):
        input_shape = self.input_shape
        return input_shape[0], self.ouput_dim

    def build(self):
        pass

    def get_initial_states(self, X):
        return alloc_zeros_matrix(X.shape[0], self.output_dim)

    def _step(self, x_t, accum_1, accum_2, inputs, prior):
        outputs = self.activation(T.dot(x_t, self.W))

# Path: seya/utils.py
# def diff_abs(z):
#     return T.sqrt(T.sqr(z)+1e-6)
# 
# def theano_rng(seed=123):
#     return MRG_RandomStreams(seed=seed)


# Path: seya/layers/coding.py
import theano
import theano.tensor as T
import numpy as np
from theano.tensor.signal.downsample import max_pool_2d
from keras.layers.core import Layer
from keras.layers.recurrent import Recurrent
from keras import activations, initializations
from keras.utils.theano_utils import alloc_zeros_matrix, sharedX
from keras.layers.convolutional import conv_output_length
from ..utils import diff_abs, theano_rng

        self.truncate_gradient = truncate_gradient
        self.activation = lambda x: .5*(1 + T.exp(-x))
        self.input = T.matrix()

        self.W = self.init((self.output_dim, self.input_dim))
        self.trainable_weights = [self.W]

        self.regularizers = []
        if W_regularizer:
            W_regularizer.set_param(self.W)
            self.regularizers.append(W_regularizer)
        if activity_regularizer:
            activity_regularizer.set_layer(self)
            self.regularizers.append(activity_regularizer)
        kwargs['input_shape'] = (None, self.input_dim)
        super(VarianceCoding, self).__init__(**kwargs)

    @property
    def output_shape(self):
        input_shape = self.input_shape
        return input_shape[0], self.ouput_dim

    def build(self):
        pass

    def get_initial_states(self, X):
        return alloc_zeros_matrix(X.shape[0], self.output_dim)

    def _step(self, x_t, accum_1, accum_2, inputs, prior):
        outputs = self.activation(T.dot(x_t, self.W))

        l1_norm = self.gamma * outputs * diff_abs(inputs)