0

Encountered the error while trying to fit model of encoder-decoder using ConvLSTM2D. the x_train is of shape (31567, 7, 210, 203, 1)(batch_size,framelength,H,W,C).

The encoder part works when executed in isolation but the error occurs when i add the decoder part, seems like the problem is in the input part of decoder but not sure.

tried reshaping the encoder_state_c_1 and encoder_state_h_1 to 5D before passing it to the decoder ConvLSTM2D but doesn't help either.

Please find the code and error here:

MODEL

def define_models_1_moving_1(framelength, n_filter, filter_size): # define training encoder encoder_inputs = Input(name = "encoder_input", shape=(x_train.shape[1], x_train.shape[2], x_train.shape[3], x_train.shape[4]))

encoder_1 = ConvLSTM2D(name = "encoder_ConvLSTM",
                       filters = n_filter, kernel_size=filter_size, padding='same', return_sequences=True, return_state=True,
                       kernel_regularizer=l2(0.0005), recurrent_regularizer=l2(0.0005), bias_regularizer=l2(0.0005))
                       # input_shape=(x_train.shape[1], x_train.shape[2], x_train.shape[3], x_train.shape[4]))

encoder_outputs_1, encoder_state_h_1, encoder_state_c_1 = encoder_1(encoder_inputs) 

# define training decoder
decoder_inputs = Input(name = "decoder_input",
                        shape=(x_train.shape[1], x_train.shape[2], x_train.shape[3], x_train.shape[4]))
decoder_1 = ConvLSTM2D(name = "decoder_ConvLSTM",
                        filters=n_filter, kernel_size=filter_size, padding='same', return_sequences=True, return_state=True,
                        kernel_regularizer=l2(0.0005), recurrent_regularizer=l2(0.0005), bias_regularizer=l2(0.0005))


decoder_outputs_1, _, _ = decoder_1([decoder_inputs, encoder_state_h_1, encoder_state_c_1]) #### This line is giving Error

model = Model([encoder_inputs, decoder_inputs], decoder_outputs_1)

return model

Error

Traceback (most recent call last):

File "D:\Chintan\Dataset\model.py", line 155, in training_history = train_1_moving_1.fit(

File "C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler raise e.with_traceback(filtered_tb) from None

File "C:\Users\Admin\AppData\Local\Temp_autograph_generated_filernuwcygs.py", line 15, in tf__train_function retval = ag__.converted_call(ag__.ld(step_function), (ag__.ld(self), ag__.ld(iterator)), None, fscope)

ValueError: in user code:

File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\training.py", line 1249, in train_function  *
    return step_function(self, iterator)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\training.py", line 1233, in step_function  **
    outputs = model.distribute_strategy.run(run_step, args=(data,))
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\training.py", line 1222, in run_step  **
    outputs = model.train_step(data)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\training.py", line 1023, in train_step
    y_pred = self(x, training=True)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\input_spec.py", line 216, in assert_input_compatibility
    raise ValueError(

ValueError: Layer "model_120" expects 2 input(s), but it received 1 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None, None, None, None, None) dtype=float32>]

0 Answers0