畅游人工智能之海--Keras教程之循环神经网络(三)

畅游人工智能之海--Keras教程之循环神经网络(三) | LSTM

什么作用

如果用一句话总结LSTM的作用,它可以用来处理时序数据;如果用一句话总结卷积的作用,它用来处理空间数据。那如果是音频呢,图片随着时间变化,那我们就会想基于卷积和LSTM的结合来解决这个问题。

什么样子

1587168739629 1587168767734在处理图像时,我们通常先将数据处理成一维向量,这个过程一般通过卷积来完成,在得到了图像的一维卷积之后,我们就可以将数据接在LSTM上了。因此LSTM的结构并没有本质改变,一个表示卷积LSTM的cell如图所示。

1587169243502

keras实现

1
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, go_backwards=False, stateful=False, dropout=0.0, recurrent_dropout=0.0)

layer的参数还是卷积和LSTM的参数,并不难理解。

无监督学习的应用

在moving-mnist数据集上对序列信息进行预测。

数据集地址:http://www.cs.toronto.edu/~nitish/unsupervised_video/mnist_test_seq.npy

代码地址:http://www.cs.toronto.edu/~nitish/unsupervised_video/unsup_video_lstm.tar.gz

在论文 Unsupervised Learning of Video Representations using LSTMs 中对该任务进行了详细描述。

http://www.cs.toronto.edu/~nitish/unsup_video.pdf