To say the conclusion first, I want to check shape of variable 'X' that is 
'sequences' parameter in theano.tensor.scan function

scan function looks like this :

    def forward(self, X):
        X.shape = (timesteps, dim)
        X.shape = (n_samples, timesteps, dim)
        print('X shape: ', X.shape)

        states, updates = theano.scan(
            outputs_info=[self.h_tm1, self.c_tm1],
                self.Ui, self.Wi,,
                self.Uf, self.Wf,,
                self.Uo, self.Wo,,
                self.Ug, self.Wg,
        print('scan end')
        updates = [(self.h_tm1, states[0][-1]), (self.c_tm1, states[1][-1])]
        return states, updates
and step function looks like this :

def step(
        x_t, h_tm1, c_tm1,
        Ui, Wi, bi, Uf, Wf, bf,
        Uo, Wo, bo, Ug, Wg, bg
        print('x_t.shape : ', x_t.shape)
        x_t.shape = (timestep=1, dim)
        x_t.shape = (n_samples, timestep=1, dim)

        i_t = T.nnet.sigmoid(, Ui) +, Wi) + bi)
        f_t = T.nnet.sigmoid(, Uf), Wf)+bf)
        o_t = T.nnet.sigmoid(, Uo) +, Wo) + bo)
        g_t = T.tanh(, Ug) +, Wg) + bg)

        c_t = c_tm1 * f_t + g_t * i_t
        h_t = T.tanh(c_t) * o_t

        return h_t, c_t

The problem is that X.shape is maybe (26,10,7002). But this is just my 
assumption (I don't know how to check it ). and  x_t is maybe (10,7002). 

But error occured when compute   'f_t = T.nnet.sigmoid(, 
Uf), Wf)+bf)' . Maybe because of shape mismatch about elem_wise

Once theano.function is begin, it is hard to check shape of numpy array(or 
 I coded '        print('x_t.shape : ', x_t.shape) in start line of step 
function. But it didn't work.
Some people say you should use 'printing.Print function'. But specifically 
want to method writing the code.

Thank you for reading this question. Truly grateful.


You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to