mobilenet_v1_1_224.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:triplet-reid 作者: VisualComputingInstitute 项目源码 文件源码
def mobilenet_v1_arg_scope(is_training=True,
                           batch_norm_decay=0.9997,
                           batch_norm_epsilon=0.001,
                           batch_norm_scale=True,
                           weight_decay=0.00004,
                           stddev=0.09,
                           regularize_depthwise=False):

  """Defines the default MobilenetV1 arg scope.
  Args:
    is_training: Whether or not we're training the model.
    batch_norm_decay: The moving average decay when estimating layer activation
      statistics in batch normalization.
    batch_norm_epsilon: Small constant to prevent division by zero when
      normalizing activations by their variance in batch normalization.
    batch_norm_scale: If True, uses an explicit `gamma` multiplier to scale the
      activations in the batch normalization layer.
    weight_decay: The weight decay to use for regularizing the model.
    stddev: The standard deviation of the trunctated normal weight initializer.
    regularize_depthwise: Whether or not apply regularization on depthwise.
  Returns:
    An `arg_scope` to use for the mobilenet v1 model.
  """
  batch_norm_params = {
      'is_training': is_training,
      'center': True,
      'scale': batch_norm_scale,
      'decay': batch_norm_decay,
      'epsilon': batch_norm_epsilon,
  }

  # Set weight_decay for weights in Conv and DepthSepConv layers.
  weights_init = tf.truncated_normal_initializer(stddev=stddev)
  regularizer = tf.contrib.layers.l2_regularizer(weight_decay)
  if regularize_depthwise:
    depthwise_regularizer = regularizer
  else:
    depthwise_regularizer = None
  with slim.arg_scope([slim.conv2d, slim.separable_conv2d],
                      weights_initializer=weights_init,
                      activation_fn=tf.nn.relu6, normalizer_fn=slim.batch_norm):
    with slim.arg_scope([slim.batch_norm], **batch_norm_params):
      with slim.arg_scope([slim.conv2d], weights_regularizer=regularizer):
        with slim.arg_scope([slim.separable_conv2d],
                            weights_regularizer=depthwise_regularizer) as sc:
          return sc
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号