Resnet tensorflow代码分析

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
  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值