凯拉斯(Keras)池中的最大随时间推移 [英] Max over time pooling in Keras
本文介绍了凯拉斯(Keras)池中的最大随时间推移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将Keras
中的CNN用于NLP任务,而不是最大池化,我试图在一段时间内实现最大池化.
I'm using CNNs in Keras
for an NLP task and instead of max pooling, I'm trying to achieve max over time pooling.
关于如何实现这一目标的任何想法/技巧?
Any ideas/hacks on how to achieve this?
我随时间推移的最大值池的意思是汇集最高值,无论它们在向量中的何处
What I mean by max over time pooling is to pool the highest value, no matter where they are in the vector
推荐答案
假设您的数据形状为(batch_size, seq_len, features)
,则可以应用:
Assuming that your data shape is (batch_size, seq_len, features)
you may apply:
seq_model = Reshape((seq_len * features, 1))(seq_model)
seq_model = GlobalMaxPooling1D()(seq_model)
这篇关于凯拉斯(Keras)池中的最大随时间推移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文