EderSantana / seya

Bringing up some extra Cosmo to Keras.
Other
377 stars 103 forks source link

TestConvGRU fails #16

Closed t13m closed 8 years ago

t13m commented 8 years ago

Hi, I ran the unit tests but failed on convGRU. I found that Recurrent.get_output() will be executed when compiling the model, which contains followed lines (Line 69 and 70):

initial_state = K.sum(initial_state, axis=1)  # (samples, input_dim)
reducer = K.zeros((self.input_dim, self.output_dim))

The self.input_dim here is None and the self.output_dim is (1, 28, 28). So the reducer can not be created correctly.

I'm not sure if I got something wrong. But I copy-pasted the get_output method to conv_rnn.py, and modified those lines like this:

        initial_states = self.get_initial_states(X)

        # if self.stateful:
        #     initial_states = self.states
        # else:
        #     # build an all-zero tensor of shape (samples, output_dim)
        #     initial_state = K.zeros_like(X)  # (samples, timesteps, input_dim)
        #     initial_state = K.sum(initial_state, axis=1)  # (samples, input_dim)
        #     reducer = K.zeros((self.batch_size, np.prod(self.output_dim)))
        #     initial_state = K.dot(initial_state, reducer)  # (samples, output_dim)
        #     initial_states = [initial_state for _ in range(len(self.states))]

And then the code can pass the tests.

EderSantana commented 8 years ago

Hi @t13m, tkx for the detailed report.

I think I pushed something to Keras doing that already: https://github.com/fchollet/keras/blob/master/keras/layers/recurrent.py#L76 Did you try updating Keras?

Let me know how ConvGRUs worked out for you.

t13m commented 8 years ago

Hi @EderSantana , the test passed after updating Keras. Thank you.