maxhodak / keras-molecules

Autoencoder network for learning a continuous representation of molecular structures.
MIT License
521 stars 146 forks source link

Convolution1D Issue #77

Closed chao1224 closed 6 years ago

chao1224 commented 6 years ago

If my understanding is right, when we use the convolution1D, the timestep should stay constant. But interestingly here, I found the structure doesn't follow this principle:

Layer (type)                     Output Shape          Param #     Connected to                     
====================================================================================================
input_15 (InputLayer)            (None, 277, 76)       0                                            
____________________________________________________________________________________________________
conv_1 (Convolution1D)           (None, 269, 9)        6165        input_15[0][0]                   
____________________________________________________________________________________________________
conv_2 (Convolution1D)           (None, 261, 9)        738         conv_1[0][0]                     
____________________________________________________________________________________________________
conv_3 (Convolution1D)           (None, 251, 10)       1000        conv_2[0][0]                     
____________________________________________________________________________________________________
flatten_1 (Flatten)              (None, 2510)          0           conv_3[0][0]                     
____________________________________________________________________________________________________
dense_1 (Dense)                  (None, 435)           1092285     flatten_1[0][0]                  
____________________________________________________________________________________________________
z_mean (Dense)                   (None, 56)            24416       dense_1[0][0]                    
____________________________________________________________________________________________________
z_log_var (Dense)                (None, 56)            24416       dense_1[0][0]                    
____________________________________________________________________________________________________
lambda (Lambda)                  (None, 56)            0           z_mean[0][0]                     
                                                                   z_log_var[0][0]                  
____________________________________________________________________________________________________
latent_input (Dense)             (None, 56)            3192        lambda[0][0]                     
____________________________________________________________________________________________________
repeat_vector (RepeatVector)     (None, 277, 56)       0           latent_input[0][0]               
____________________________________________________________________________________________________
gru_1 (GRU)                      (None, 277, 501)      838674      repeat_vector[0][0]              
____________________________________________________________________________________________________
gru_2 (GRU)                      (None, 277, 501)      1507509     gru_1[0][0]                      
____________________________________________________________________________________________________
gru_3 (GRU)                      (None, 277, 501)      1507509     gru_2[0][0]                      
____________________________________________________________________________________________________
decoded_mean (TimeDistributed)   (None, 277, 76)       38152       gru_3[0][0]                      
====================================================================================================
Total params: 5,044,056
Trainable params: 5,044,056
Non-trainable params: 0

From conv2 to conv3, the dim is increasing, and timestep is reducing. Is this a bug in keras or if I miss sth?

gregkoytiger commented 6 years ago

It is because of the lack of padding. This causes contraction because the convolutions are not defined at the end and beginning of the SMILES string.