Keras 中的最大随时间池化 [英] Max over time pooling in Keras

查看:28
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆