解读MaxPooling1D和GlobalMaxPooling1D的区别
作者:zhangztSky 发布时间:2023-07-21 10:54:43
标签:MaxPooling1D,GlobalMaxPooling1D
MaxPooling1D和GlobalMaxPooling1D区别
import tensorflow as tf
from tensorflow import keras
input_shape = (2, 3, 4)
x = tf.random.normal(input_shape)
print(x)
y=keras.layers.GlobalMaxPool1D()(x)
print("*"*20)
print(y)
'''
"""Global average pooling operation for temporal data.
Examples:
>>> input_shape = (2, 3, 4)
>>> x = tf.random.normal(input_shape)
>>> y = tf.keras.layers.GlobalAveragePooling1D()(x)
>>> print(y.shape)
(2, 4)
Arguments:
data_format: A string,
one of `channels_last` (default) or `channels_first`.
The ordering of the dimensions in the inputs.
`channels_last` corresponds to inputs with shape
`(batch, steps, features)` while `channels_first`
corresponds to inputs with shape
`(batch, features, steps)`.
Call arguments:
inputs: A 3D tensor.
mask: Binary tensor of shape `(batch_size, steps)` indicating whether
a given step should be masked (excluded from the average).
Input shape:
- If `data_format='channels_last'`:
3D tensor with shape:
`(batch_size, steps, features)`
- If `data_format='channels_first'`:
3D tensor with shape:
`(batch_size, features, steps)`
Output shape:
2D tensor with shape `(batch_size, features)`.
"""
'''
print("--"*20)
input_shape = (2, 3, 4)
x = tf.random.normal(input_shape)
print(x)
y=keras.layers.MaxPool1D(pool_size=2,strides=1)(x) # strides 不指定 默认等于 pool_size
print("*"*20)
print(y)
输出如下图
上图GlobalMaxPool1D 相当于给每一个样本每列的最大值
而MaxPool1D就是普通的对每一个样本进行一个窗口(1D是一维列窗口)滑动取最大值。
tf.keras.layers.GlobalMaxPool1D()
与tf.keras.layers.Conv1D的输入一样,输入一个三维数据(batch_size,feature_size,output_dimension)
x = tf.constant([[1., 2., 3.], [4., 5., 6.]])
x = tf.reshape(x, [2, 3, 1])
max_pool_1d=tf.keras.layers.GlobalMaxPooling1D()
max_pool_1d(x)
其中max_pool_1d(x)和tf.math.reduce_max(x,axis=-2,keepdims=False)作用相同
来源:https://blog.csdn.net/qq_38574975/article/details/111468756
0
投稿
猜你喜欢
- 本文实例为大家分享了ADO.NET通用数据库访问类,供大家参考学习,具体内容如下using System;using System.Coll
- 本文实例为大家分享了python五子棋游戏的具体代码,供大家参考,具体内容如下目录简介实现过程结语简介使用python实现pygame版的五
- 这个验证类的完成有很长时间了,一直没有分享给大家使用了这么长时间之后感觉挺顺手,用于一些不需要特殊效果的表单验证个人认为已经足够了,还是挺好
- 这篇文章主要介绍了python列表推导式操作解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以
- 以前的Sony Ericsson牌DVD影碟机坏掉了,上周到沃尔玛买了个philips的回来,于是又淘了一些DVD回来看。在使用遥控的时候忽
- 这篇文章主要介绍了Python手绘可视化工具cutecharts使用实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考
- 前言如果一个类是别人编写的,又没有帮助文档,怎么样来查看所有成员函数呢?本文详细给大家介绍了关于python用dir函数查看类中所有成员函数
- 数据库相关错误的解决办法错误一:数据库连接池超过限制SqlAlchemy QueuePool limit overflow造成连接数超过数据
- 下面请看本文详细介绍.Perl字符串处理函数1. index语法:position=index(string,substring,posit
- 本文实例为大家分享了python实现微信自动回复的具体代码,供大家参考,具体内容如下新年到了,不想让一早上给你发送祝福的人心里一阵寒风,可以
- 在开发过程中,经常会通过实例的vm.$refs(this.$refs)取得通过ref注册过的组件,并进行相应操作,但存在取不到元素的情况,其
- 前言:在Vue项目中,当访问的页面路由不存在或错误时,页面显示为一片空白。然而,通常我们需要对访问url不存在或者错误的情况下添加默认的40
- python学生成绩管理系统创建,供大家参考,具体内容如下要求编写学生类,班级类,并在电脑运行生成表单,输入一个数字,得到对应的结果。输出样
- python作为一门动态语言,在使用变量之前是不需要进行定义,而是通过动态绑定的方法将变量绑定为某种类型。这样做为我们使用变量时提供了方便,
- ///计算两个整数的百分比值 function GetPercent(num, total) { num = parseFloat(num)
- 1.绘制面积图面积图常用于描述某指标随时间的变化程度。其面积也通常可以有一定的含义。绘制面积图使用的是plt.stackplot()方法。以
- 英文版:File -> settings -> Editor -> File Encodings首先打开设置:文件 -&g
- python安装reportlabpip install reportlab -i http://pypi.douban.com/simpl
- 正态分布(Normal distribution)又成为高斯分布(Gaussian distribution)若随机变量X服从一个数学期望为
- 一、正则表达式的特殊字符介绍正则表达式^ 匹配行首 &nb