python-3.x - coursera 上具有 stride 2 深度学习专业化的 1X1 过滤器
问题描述
我正在学习 Coursera 的深度学习专业。在课程4(ResNets)的第二周作业中,有以下代码
在# First component of main path
Conv2D 函数中有参数F1, (1, 1), strides = (s,s)
。这是否意味着它是一个步长为 2 的 1X1 过滤器?这没有任何意义,因为我们会丢失一个备用像素。我的理解正确吗?
# GRADED FUNCTION: convolutional_block
def convolutional_block(X, f, filters, stage, block, s = 2):
"""
Implementation of the convolutional block as defined in Figure 4
Arguments:
X -- input tensor of shape (m, n_H_prev, n_W_prev, n_C_prev)
f -- integer, specifying the shape of the middle CONV's window for the main path
filters -- python list of integers, defining the number of filters in the CONV layers of the main path
stage -- integer, used to name the layers, depending on their position in the network
block -- string/character, used to name the layers, depending on their position in the network
s -- Integer, specifying the stride to be used
Returns:
X -- output of the convolutional block, tensor of shape (n_H, n_W, n_C)
"""
# defining name basis
conv_name_base = 'res' + str(stage) + block + '_branch'
bn_name_base = 'bn' + str(stage) + block + '_branch'
# Retrieve Filters
F1, F2, F3 = filters
# Save the input value
X_shortcut = X
##### MAIN PATH #####
# First component of main path
X = Conv2D(F1, (1, 1), strides = (s,s), name = conv_name_base + '2a', kernel_initializer = glorot_uniform(seed=0))(X)
X = BatchNormalization(axis = 3, name = bn_name_base + '2a')(X)
X = Activation('relu')(X)
解决方案
推荐阅读
- java - 使用 RESTEasy / Jackson / Quarkus 将 JTS 几何解析为 GeoGSON
- python - 带有 for 循环和 if-else 语句的 Lambda 函数
- c++ - 没有匹配的函数来调用“擦除”(std::vector)
- git - git rebase 一个浮动分支
- vue.js - Vue.js Build.js 脚本不会终止
- spring-boot - 我的代码在tomcat中有效,但在websphere中没有?
- java - 同步和并发集合如何是线程安全的,但它们的内容不是
- javascript - 当 iOS Safari 中的页面可见性更改时无法播放视频
- powerbi - 销售加权值
- angular - PrimeNg (7.x) p 下拉布尔值