# Path: seya/utils.py
# def apply_model(model, X):
#     tmp = model.layers[0].get_input
#     model.layers[0].get_input = lambda _: X
#     Y = model.get_output()
#     model.layers[0].get_input = tmp
# 
#     return Y


import theano
import theano.tensor as T
from keras.layers.recurrent import GRU
from keras.utils.theano_utils import shared_zeros
from seya.utils import apply_model
        self.init_h = shared_zeros((self.state_dim,))
        # here is difference on the sizes
        input_dim = self.input_shape[2] + self.readout.output_shape[1]

        # copy-paste from keras.recurrent.GRU
        self.W_z = self.init((input_dim, self.state_dim))
        self.U_z = self.inner_init((self.state_dim, self.state_dim))
        self.b_z = shared_zeros((self.state_dim))

        self.W_r = self.init((input_dim, self.state_dim))
        self.U_r = self.inner_init((self.state_dim, self.state_dim))
        self.b_r = shared_zeros((self.state_dim))

        self.W_h = self.init((input_dim, self.state_dim))
        self.U_h = self.inner_init((self.state_dim, self.state_dim))
        self.b_h = shared_zeros((self.state_dim))

        self.trainable_weights = [
            self.init_h,
            self.W_z, self.U_z, self.b_z,
            self.W_r, self.U_r, self.b_r,
            self.W_h, self.U_h, self.b_h,
        ]

        if self.initial_weights is not None:
            self.set_weights(self.initial_weights)
            del self.initial_weights

    def _get_initial_states(self, batch_size):
        init_h = T.repeat(self.init_h.dimshuffle('x', 0), batch_size, axis=0)

# Path: seya/utils.py
# def apply_model(model, X):
#     tmp = model.layers[0].get_input
#     model.layers[0].get_input = lambda _: X
#     Y = model.get_output()
#     model.layers[0].get_input = tmp
# 
#     return Y


# Path: seya/layers/readout.py
import theano
import theano.tensor as T
from keras.layers.recurrent import GRU
from keras.utils.theano_utils import shared_zeros
from seya.utils import apply_model

        self.init_h = shared_zeros((self.state_dim,))
        # here is difference on the sizes
        input_dim = self.input_shape[2] + self.readout.output_shape[1]

        # copy-paste from keras.recurrent.GRU
        self.W_z = self.init((input_dim, self.state_dim))
        self.U_z = self.inner_init((self.state_dim, self.state_dim))
        self.b_z = shared_zeros((self.state_dim))

        self.W_r = self.init((input_dim, self.state_dim))
        self.U_r = self.inner_init((self.state_dim, self.state_dim))
        self.b_r = shared_zeros((self.state_dim))

        self.W_h = self.init((input_dim, self.state_dim))
        self.U_h = self.inner_init((self.state_dim, self.state_dim))
        self.b_h = shared_zeros((self.state_dim))

        self.trainable_weights = [
            self.init_h,
            self.W_z, self.U_z, self.b_z,
            self.W_r, self.U_r, self.b_r,
            self.W_h, self.U_h, self.b_h,
        ]

        if self.initial_weights is not None:
            self.set_weights(self.initial_weights)
            del self.initial_weights

    def _get_initial_states(self, batch_size):
        init_h = T.repeat(self.init_h.dimshuffle('x', 0), batch_size, axis=0)

        init_o = apply_model(self.readout, init_h)