tensorflow - Python Keras : An layer output exactly the same thing as input

标签 tensorflow keras lstm keras-layer keras-2

我正在使用 Keras 构建网络。在这个过程中,我需要一个层,它接受一个 LSTM 输入,什么都不做,只是输出和输入完全一样。即如果 LSTM 的每个输入记录都像 [[A_t1, A_t2, A_t3, A_t4, A_t5, A_t6]],我正在寻找一个层:

model.add(SomeIdentityLayer(x))

SomeIdentityLayer(x) 将采用 [[A_t1, A_t2, A_t3, A_t4, A_t5, A_t6]]作为输入和输出 [[A_t1, A_t2, A_t3, A_t4, A_t5, A_t6]] . Keras 中有这样的层/结构吗?谢谢!

最佳答案

对于更简单的操作,比如身份,你可以只使用一个 Lambda 层,如:
model.add(Lambda(lambda x: x))
这将返回与您的输入完全相同的输出。

关于tensorflow - Python Keras : An layer output exactly the same thing as input,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47297779/

相关文章:

python - 为什么 GAN 无法从某些分布中生成样本?

python - 将 CNN 的输出传递给 BILSTM

python - ValueError : Input 0 of layer lstm is incompatible with the layer: expected ndim=3, 发现 ndim=2。收到完整形状 : [None, 18]

python - 如何在日期序列上训练 LSTM?

python - 未找到 : Container localhost does not exist when I load model with tensorflow and flask

tensorflow - LSTM 如何知道 Conv1D-LSTM 网络中的时间步数和特征?

Python - 由于缺少 DLL,Tensorflow 将无法导入

tensorflow - 家庭监控,TensorFlow(+ OpenCV)

python - 未知层 : KerasLayer when i try to load_model

Keras LSTM 状态与带滑动窗口的前馈网络