池化与采样
2021/4/15 18:58:22
本文主要是介绍池化与采样,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
目录
- Outline
- Reduce Dim
- subsample
- Max/Avg pooling
- Strides
- For instance
- upsample
- UpSampling2D
- ReLu
Outline
Pooling
upsample
ReLU
Reduce Dim
subsample
Max/Avg pooling
- stride = 2
Strides
- stride = 1
For instance
import tensorflow as tf from tensorflow.keras import layers
x = tf.random.normal([1, 14, 14, 4]) x.shape
TensorShape([1, 14, 14, 4])
pool = layers.MaxPool2D(2, strides=2) out = pool(x) out.shape
TensorShape([1, 7, 7, 4])
pool = layers.MaxPool2D(3, strides=2) out = pool(x) out.shape
TensorShape([1, 6, 6, 4])
out = tf.nn.max_pool2d(x, 2, strides=2, padding='VALID') out.shape
TensorShape([1, 7, 7, 4])
upsample
nearest
bilinear
UpSampling2D
x = tf.random.normal([1, 7, 7, 4]) x.shape
TensorShape([1, 7, 7, 4])
layer = layers.UpSampling2D(size=3) out = layer(x) out.shape
TensorShape([1, 21, 21, 4])
layer = layers.UpSampling2D(size=2) out = layer(x) out.shape
TensorShape([1, 14, 14, 4])
ReLu
x = tf.random.normal([2,3]) x
<tf.Tensor: id=76, shape=(2, 3), dtype=float32, numpy= array([[-0.30181265, 0.39785287, -0.78380096], [ 0.6593401 , -0.40962896, -0.3656048 ]], dtype=float32)>
tf.nn.relu(x) x
<tf.Tensor: id=76, shape=(2, 3), dtype=float32, numpy= array([[-0.30181265, 0.39785287, -0.78380096], [ 0.6593401 , -0.40962896, -0.3656048 ]], dtype=float32)>
layers.ReLU()(x)
<tf.Tensor: id=80, shape=(2, 3), dtype=float32, numpy= array([[0. , 0.39785287, 0. ], [0.6593401 , 0. , 0. ]], dtype=float32)>
这篇关于池化与采样的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南