farizrahman4u / seq2seq

Sequence to Sequence Learning with Keras
GNU General Public License v2.0
3.17k stars 845 forks source link

ValueError: Cannot feed value of shape (32, 10, 3) for Tensor u'input_1231:0', which has shape '(16, 10, 3)' #247

Open chengfeifan opened 6 years ago

chengfeifan commented 6 years ago

The shape of my train data normal_scale is (398,10,3),I try the following code, but it turns a shape error.


import seq2seq
from seq2seq.models import Seq2Seq

model = Seq2Seq(batch_input_shape=(16, 10, 3), hidden_dim=10, output_length=10, output_dim=3, depth=4)
model.compile(loss='mse', optimizer='rmsprop')
model.summary()
model.fit(x=normal_scale,y=normal_scale)

My model is

_________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_1231 (InputLayer)         (16, 10, 3)          0                                            
__________________________________________________________________________________________________
time_distributed_19 (TimeDistri (16, 10, 10)         40          input_1231[0][0]                 
__________________________________________________________________________________________________
private__optional_input_place_h (2,)                 0                                            
__________________________________________________________________________________________________
private__optional_input_place_h (2,)                 0                                            
__________________________________________________________________________________________________
private__optional_input_place_h (2,)                 0                                            
__________________________________________________________________________________________________
recurrent_sequential_37 (Recurr [(16, 10), (16, 10), 3360        time_distributed_19[0][0]        
                                                                 private__optional_input_place_hol
                                                                 private__optional_input_place_hol
                                                                 private__optional_input_place_hol
__________________________________________________________________________________________________
dense_856 (Dense)               (16, 3)              33          recurrent_sequential_37[0][0]    
__________________________________________________________________________________________________
recurrent_sequential_38 (Recurr (16, 10, 3)          2372        dense_856[0][0]                  
                                                                 recurrent_sequential_37[0][1]    
                                                                 recurrent_sequential_37[0][2]    
                                                                 dense_856[0][0]                  
==================================================================================================
Total params: 5,805
Trainable params: 5,805
Non-trainable params: 0

Actually I don't have data shape of (32, 10, 3) , the error is

ValueError: Cannot feed value of shape (32, 10, 3) for Tensor u'input_1231:0', which has shape '(16, 10, 3)'

chengfeifan commented 6 years ago

Actually I find the sample of data must be the whole-number multiple of the batch_size,and you need to set the batch_size at the model.fit