resnet
论文:https://arxiv.org/pdf/1512.03385.pdf
翻译转载:https://blog.csdn.net/Quincuntial/article/details/77263562
网络结构1:https://blog.csdn.net/nima1994/article/details/82686132
网络结构2:https://blog.csdn.net/seven_year_promise/article/details/69360488
这几天看了tensorflow搭建的resnet模型,十分的干净利落。将结合代码的分析记录,以防遗忘。
模型位于 /tensorflow/model/research/slim/nets/resnet_v1.py
在该文件中可以直接找到 resnet_v1_50 函数,这是最基础的resnet网络模型,与101,152的结构是一致的,所以就此进行分析。
def resnet_v1_50(inputs,
num_classes=None,
is_training=True,
global_pool=True,
output_stride=None,
spatial_squeeze=True,
store_non_strided_activations=False,
reuse=None,
scope='resnet_v1_50'):
"""ResNet-50 model of [1]. See resnet_v1() for arg and return description."""
blocks = [
resnet_v1_block('block1', base_depth=64, num_units=3, stride=2),
resnet_v1_block('block2', base_depth=128, num_units=4, stride=2),
resnet_v1_block('block3', base_depth=256, num_units=6, stride=2),
resnet_v1_block('block4', base_depth=512, num_units=3, stride=1),
]
return resnet_v1(inputs, blocks, num_classes, is_training,
global_pool=global_pool, output_stride=output_stride,
include_root_block=True, spatial_squeeze=spatial_squeeze,
store_non_strided_activations=store_non_strided_activations,
reuse=reuse, scope=scope)
resnet_v1_50.default_image_size = resnet_v1.default_image_size
可以看到该blocks直接由4个resnet_v1_block顺次构成,好简洁。。。结合论文中给出了网络结构模型进行分析。
可以看到论文中resnet50的resnet模块就是3,4,6,3的分布卷积核数目分别是64,128,256,512,这一部分意义印证。
接下来进入到 resnet_v1_block 函数
def resnet_v1_block(scope, base_depth, num_units, stride):
"""Helper function for creating a resnet_v1 bottleneck block.
Args:
scope: The scope of the block.
base_depth: The depth of the bottleneck l