PeterChe1990 / GRU-D

GRU-D, a GRU-based model with trainable decays for multivariate time series classification with missing values/irregular samplings
MIT License
118 stars 37 forks source link

Undefined kernel_z, kernel_h and kernel_h attributes in GRUDCell() class #6

Closed quarkmatter closed 2 years ago

quarkmatter commented 2 years ago

Hi,

I'm trying to run the GRUD on the data bricks platform for my research and there seems to be some undefined attributes used when calling the CRUDCell. I run the following code:

model = create_grud_model(input_dim=17, output_dim=17, output_activation='sigmoid', recurrent_dim=[64], hidden_dim=[64] )

And I end up with the following:

AttributeError: 'GRUDCell' object has no attribute 'kernel_z'

Digging a bit furthering grud_layers.py, you have the following on lines 278-280:

278     z_t = K.dot(x_z, self.kernel_z) + K.dot(h_tm1_z, self.recurrent_kernel_z)   
279     r_t = K.dot(x_r, self.kernel_r) + K.dot(h_tm1_r, self.recurrent_kernel_r)
280     hh_t = K.dot(x_h, self.kernel_h)

But self.kernel_ and self.recurrent_kernel_ are not defined anywhere in the GRUDCell class.I am pretty new to this level of tensor flow/keras so I'm not sure exactly what these should be in the pipeline, so I can't hack it together myself. Can you please help?

Yovoss commented 2 years ago

@quarkmatter I have modified the tensorflow.keras.recurrent.py, and return the self.kernel_ and self.recurrentkernel for grud_layer.py, which seems working. But there are warning: "WARNING:tensorflow:Gradients do not exist for variables ['grud/kernel:0', 'grud/recurrent_kernel:0', 'grud/bias:0', 'grud/masking_kernel:0'] when minimizing the loss." I am not sure about the consequences of this warning.

PeterChe1990 commented 2 years ago

Please strictly follow the package dependencies in requirements.txt, as running on later versions has not been tested.