https://github.com/keras-team/keras/blob/master/keras/layers/convolutional_recurrent.py
从keras的源码学习一下convLSTM的实现,有助于理解convLSTM的原理
ConvLSTM把LSTM中的全连接操作换成了卷积的形式,可以更好的提取出图像的特征
keras里ConvLSTM2D的参数和输入
https://keras.io/api/layers/recurrent_layers/conv_lstm2d/
tf.keras.layers.ConvLSTM2D(
filters,
kernel_size,
strides=(1, 1),
padding="valid",
data_format=None,
dilation_rate=(1, 1),
activation="tanh",
recurrent_activation="hard_sigmoid",
use_bias=True,
kernel_initializer="glorot_uniform",
recurrent_initializer="orthogonal",
bias_initializer="zeros",
unit_forget_bias=True,
kernel_regularizer=None,
recurrent_regularizer=None,
bias_regularizer=None,
activity_regularizer=None,
kernel_constraint=None,
recurrent_constraint=None,
bias_constraint=None,
return_sequences=False,
return_state=False,
go_backwards=False,
stateful=False,
dropout=0.0,
recurrent_dropout=0.0,
**kwargs
)
几个重要的输入参数:
- filters: Integer, the dimensionality of the output space (i.e. the number of output filters in the convolution).
- kernel_size: An integer or tuple/list of n integers, specifying the dimensions of the convolution window.
调用时:
- inputs: A 5D tensor.
5D tensor with shape: (samples, time, channels, rows, cols) - If data_format=‘channels_last’ 5D tensor with shape: (samples, time, rows, cols, channels)
Output shape
- If return_state: a list of tensors. The first tensor is the output. The remaining tensors are the last states, each 4D tensor with shape: (samples, filters, new_rows, new_cols) if data_format=‘channels_first’ or shape: (samples, new_rows, new_cols, filters) if data_format=‘channels_last’. rows and cols values might have changed due to padding.
- If return_sequences: 5D tensor with shape: (samples, timesteps, filters, new_rows, new_cols) if data_format=‘channels_first’ or shape: (samples, timesteps, new_rows, new_cols, filters) if data_format=‘channels_last’.
- Else, 4D tensor with shape: (samples, filters, new_rows, new_cols) if data_format=‘channels_first’ or shape: (samples, new_rows, new_cols, filters) if data_format=‘channels_last’.