|
import tensorflow as tf |
|
from tensorflow.keras.layers import ( |
|
ConvLSTM2D, Input, Conv2D, BatchNormalization, Add, ReLU, TimeDistributed |
|
) |
|
|
|
def build_residual_convlstm_model_seq2seq(input_shape): |
|
input_layer = Input(shape=input_shape) |
|
|
|
|
|
x = ConvLSTM2D(filters=128, kernel_size=(3, 3), padding='same', return_sequences=True)(input_layer) |
|
x = BatchNormalization()(x) |
|
res = x |
|
|
|
|
|
x = ConvLSTM2D(filters=128, kernel_size=(3, 3), padding='same', return_sequences=True)(x) |
|
x = BatchNormalization()(x) |
|
|
|
|
|
x = Add()([x, res]) |
|
|
|
|
|
x = ConvLSTM2D(filters=128, kernel_size=(3, 3), padding='same', return_sequences=True)(x) |
|
x = BatchNormalization()(x) |
|
|
|
|
|
x = TimeDistributed(Conv2D(128, (3, 3), padding='same'))(x) |
|
x = TimeDistributed(ReLU())(x) |
|
|
|
|
|
output_layer = TimeDistributed(Conv2D(1, (3, 3), activation='sigmoid', padding='same'))(x) |
|
|
|
model = tf.keras.Model(inputs=input_layer, outputs=output_layer) |
|
return model |
|
|