TimeDistributed 与 TimeDistributedDense Keras

TimeDistributed vs. TimeDistributedDense Keras

我已经完成了 official documentation,但仍然无法理解 TimeDistributed 作为 Keras 模型中的层实际上做了什么?

我无法理解 TimeDistributedTimeDistributedDense 之间的区别?什么时候会有人使用TimeDistributedDense?只是为了减少训练数据集吗?它还有其他好处吗?

任何人都可以用一个精确的例子来解释这两种类型的层包装器的作用吗?

所以 - 基本上 TimeDistributedDense 是在 Keras 的早期版本中首先引入的,以便将 Dense 层逐步应用于序列。 TimeDistributed 是一个 Keras 包装器,它可以获取任何静态(非顺序)层并以顺序方式应用它。所以如果例如由于 TimeDistributed 包装器,您的图层接受形状为 (d1, .., dn) 的输入,您的图层可以通过应用提供给 X[0,:,:,..,:] 的图层接受形状为 (sequence_len, d1, ..., dn) 的输入,X[1,:,...,:]...X[len_of_sequence,:,...,:]

这种用法的一个例子可能是使用例如通过应用 TimeDistributed(conv_layer) 将预训练的卷积层应用于短视频剪辑,其中 conv_layer 应用于剪辑的每一帧。它产生输出序列,然后可能被下一个循环或 TimeDistributed 层消耗。

很高兴知道 TimeDistributedDense 的使用已贬值,最好使用 TimeDistributed(Dense)

TimeDistributedDenseTimeDistributed 相同,唯一的区别是 TimeDistributed 可以用于不同类型的层,而不仅仅是 Dense 层。

Keras 文档说 TimeDistributed :

"Note this is strictly equivalent to using layers.core.TimeDistributedDense. However what is different about TimeDistributed is that it can be used with arbitrary layers, not just Dense, for instance with a Convolution2D layer"