MaxPooling1D和globalMaxPooling1D的区别

1.GlobalMaxPooling1D:
在steps维度(也就是第二维)对整个数据求最大值。
比如说输入数据维度是[10, 4, 10],那么进过全局池化后,输出数据的维度则变成[10, 10]。

是对步长维度的向量求最大值。故会产生维度压缩

2.MaxPooling1D:
也是在steps维度(也就是第二维)求最大值。但是限制每一步的池化的大小。 比如,输入数据维度是[10, 4, 10],池化层大小pooling_size=2,步长stride=1,那么经过MaxPooling(pooling_size=2, stride=1)后,输出数据维度是[10, 3, 10]。

是对每一次卷积的kernel内的向量求最大值,产生一个新的向量。而没有做额外多余的处理。
 

the  [[.7, -0.2, .1]   |池化大小是2,所以一次选两个字,首先对                
boy   [.8, -.3,  .2]   | 前两个向量求最大值,也就是the和boy。   | 步长是1,移动到
will  [.2, -.1,  .4]                                       | boy和will
live  [.4  -.4,  .8]]  

池化层处理时并未增加新的变量和参数。

Keras学习笔记(四):MaxPooling1D和GlobalMaxPooling1D的区别_林夕-CSDN博客_maxpooling1d

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
下面是一个基于 TextCNN 和 LSTM 的招聘简历自动筛选系统的 Python 代码示例: ```python import numpy as np from tensorflow.keras.preprocessing.text import Tokenizer from tensorflow.keras.preprocessing.sequence import pad_sequences from tensorflow.keras.layers import Dense, Input, LSTM, Embedding, Dropout, Activation, Conv1D, GRU, CuDNNGRU, CuDNNLSTM, BatchNormalization from tensorflow.keras.layers import Bidirectional, GlobalMaxPool1D, MaxPooling1D, Add, Flatten from tensorflow.keras.layers import GlobalAveragePooling1D, GlobalMaxPooling1D, concatenate, SpatialDropout1D from tensorflow.keras.models import Model, load_model from tensorflow.keras import initializers, regularizers, constraints, optimizers, layers, callbacks from tensorflow.keras import backend as K from tensorflow.keras.engine import InputSpec, Layer from tensorflow.keras.optimizers import Adam # 读取数据 resumes = [] labels = [] with open("resumes.txt", "r") as f: for line in f: resumes.append(line.strip().split("\t")[0]) labels.append(int(line.strip().split("\t")[1])) # 划分训练集和测试集 X_train, X_test, y_train, y_test = train_test_split(resumes, labels, test_size=0.2, random_state=42) # 数据预处理 max_features = 20000 maxlen = 100 tokenizer = Tokenizer(num_words=max_features) tokenizer.fit_on_texts(X_train) X_train = tokenizer.texts_to_sequences(X_train) X_test = tokenizer.texts_to_sequences(X_test) x_train = pad_sequences(X_train, maxlen=maxlen) x_test = pad_sequences(X_test, maxlen=maxlen) # 构建模型 def build_model(): inp = Input(shape=(maxlen,)) x = Embedding(max_features, 128)(inp) x = SpatialDropout1D(0.2)(x) x = Bidirectional(CuDNNLSTM(64, return_sequences=True))(x) y = Bidirectional(CuDNNGRU(64, return_sequences=True))(x) avg_pool1 = GlobalAveragePooling1D()(y) max_pool1 = GlobalMaxPooling1D()(y) conc = concatenate([avg_

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

会发paper的学渣

您的鼓励和将是我前进的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值