keras里的convLSTM实现

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’.

使用实例

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
addition_rnn.py 执行序列学习以执行两个数字(作为字符串)的添加。 antirectifier.py 演示如何为Keras编写自定义图层。 babi_memnn.py 在bAbI数据集上训练一个内存网络以进行阅读理解。 babi_rnn.py 在bAbI数据集上训练一个双支循环网络,以便阅读理解。 cifar10_cnn.py 在CIFAR10小图像数据集上训练一个简单的深CNN。 conv_filter_visualization.py 通过输入空间中的渐变上升可视化VGG16的过滤器。 conv_lstm.py 演示使用卷积LSTM网络。 deep_dream.py 深深的梦想在克拉斯。 image_ocr.py 训练一个卷积堆叠,后跟一个循环堆栈和一个CTC logloss函数来执行光学字符识别(OCR)。 imdb_bidirectional_lstm.py 在IMDB情绪分类任务上训练双向LSTM。 imdb_cnn.py 演示使用Convolution1D进行文本分类。 imdb_cnn_lstm.py 在IMDB情绪分类任务上训练一个卷积堆栈,后跟一个循环堆栈网络。 imdb_fasttext.py 在IMDB情绪分类任务上训练一个FastText模型。 imdb_lstm.py 在IMDB情绪分类任务上训练一个LSTMlstm_benchmark.py 比较IMDB情绪分类任务上不同的LSTM实现lstm_text_generation.py 生成尼采文字的文字。 mnist_acgan.py 在MNIST数据集上实现AC-GAN(辅助分类器GAN) mnist_cnn.py 在MNIST数据集上训练一个简单的convnet。 mnist_hierarchical_rnn.py 训练一个分级RNN(HRNN)来分类MNIST数字。 mnist_irnn.py Le等人在“以简单的方式初始化整流线性单元的反复网络”中再现具有逐像素连续MNIST的IRNN实验。 mnist_mlp.py 在MNIST数据集上训练一个简单的深层多层感知器。 mnist_net2net.py 在“Net2Net:通过知识转移加速学习”中再现带有MNIST的Net2Net实验。 mnist_siamese_graph.py 从MNIST数据集中的一对数字上训练暹罗多层感知器。 mnist_sklearn_wrapper.py 演示如何使用sklearn包装器。 mnist_swwae.py 列出了一个堆栈,其中AutoEncoder在MNIST数据集上的剩余块上构建。 mnist_transfer_cnn.py 转移学习玩具的例子。 neural_doodle.py 神经涂鸦。 neural_style_transfer.py 神经样式转移。 pretrained_word_embeddings.py 将预训练的词嵌入(GloVe embeddings)加载到冻结的Keras嵌入层中,并使用它在20个新闻组数据集上训练文本分类模型。 reuters_mlp.py 在路透社newswire主题分类任务上训练并评估一个简单的MLP。 stateful_lstm.py 演示如何使用有状态的RNN有效地建模长序列。 variational_autoencoder.py 演示如何构建变体自动编码器。 variational_autoencoder_deconv.py 演示如何使用反褶积层使用Keras构建变体自动编码器。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值