slim的batch_norm出现的问题

在将FastMaskRCNN代码中的is_training参数从True改为False后,测试结果显著变化。问题追溯到resnet_v1函数和slim库的batch_norm。尽管dropout和is_training无关,但batch_norm的is_training参数在测试和训练模式下的不同行为导致了问题。在`with slim.arg_scope([slim.batch_norm], is_training=True)`中将is_training设回True解决了问题,但在测试场景中这样做并不理想。" 115789649,10723135,C语言实现的顺序表数据结构详解,"['C语言', '数据结构', '顺序表']
摘要由CSDN通过智能技术生成

python代码有一个好处,就是容易编写。但它的坏处也是大大的,好难读啊!!!

以下代码来自FastMaskRCNN(https://github.com/CharlesShang/FastMaskRCNN),在实际运行过程中,把is_training由True改为False后,测试结果大不一样!折腾了几天时间。后来找到了一个解决方法。锁定目标在resnet_v1函数上。

代码内容总揽(ResNet v1模型生成器)


def resnet_v1(inputs,
              blocks,
              num_classes=None,
              is_training=True,
              global_pool=True,
              output_stride=None,
              include_root_block=True,
              spatial_squeeze=True,
              reuse=None,
              scope=None):
  """Generator for v1 ResNet models.

  This function generates a family of ResNet v1 models. See the resnet_v1_*()
  methods for specific model instantiations, obtained by selecting different
  block instantiations that produce ResNets of various depths.

  Training for image classification on Imagenet is usually done with [224, 224]
  inputs, resulting in [7, 7] feature maps at the output of the last ResNet
  block for the ResNets defined in [1] that have nominal stride equal to 32.
  However, for dense prediction tasks we advise that one uses inputs with
  spatial dimensions that are multiples of 32 plus 1, e.g., [321, 321]. In
  this case the feature maps at the ResNet output will have spatial shape
  [(height - 1) / output_stride + 1, (width - 1) / output_stride + 1]
  and corners exactly aligned with the input image corners, which greatly
  facilitates alignment of the features to the image. Using as input [225, 225]
  images results in [8, 8] feature maps at the output of the last ResNet block.

  For dense prediction tasks, the ResNet needs to run in fully-convolutional
  (FCN) mode and global_pool needs to be set to False. The ResNets in [1, 2] all
  have nominal stride equal to 32 and a good choice in FCN mode is to use
  output_stride=16 in order to increase the density of the computed features at
  small computational and memory ove
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 11
    评论
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值