【DropBlock】Deep Learning Technology

The paper records the newest deep learning technology

一、 DropBlock

1. Theory and Practice

  • Choose Anchor to be dropped:
    • 操作:选中(feat_size - block_size -1)的中间区域,使用γ作为伯努利分布的均值,随机需要drop的点,用❌表示选中(feat_size - block_size -1)的中间区域,使用γ作为伯努利分布的均值,随机需要drop的点,用❌表示
    • 原理:Equation(1)
  • Expand zero entry to zero block
    • 操作:❌周围[block_size block_size]的box也视为要drop的点❌周围[block_size block_size]的box也视为要drop的点
    • 原理:dropping continuous regions can remove certain semantic> dropping continuous regions can remove certain semantic information (e.g., head or feet) and consequently enforcing remaining units to learn features for
      classifying input image.
    • 效果:Figure 1
  • Apply Mask and Normalize
    • 操作:step 7,8 in Algorithm 1 DropBlock

2. Paper and Implements

3. Other Dropout Strategies

  • Dropout:完全随机扔
  • SpatialDropout:按channel随机扔
  • Stochastic Depth:按res block随机扔
  • DropBlock:每个feature map上按spatial块随机扔
  • Cutout:在input层按spatial块随机扔
  • DropConnect:只在连接处扔,神经元不扔。

4. Tensorflow

github上给出的dropblock-tensorflow版本(tf)亲测发现仅仅只能用于前馈(因为必须要求输入的维度已知,而不能为None);keras版跟tf结合的时候也会碰到一些问题。
因此,这里基于网上的tf实现,给出可以在训练中实际使用的tensorflow版本的dropBlock,亲测对于psnr带来0.02到0.04不同程度的提升
代码如下:

import tensorflow as tf

def dropblock(x, keep_prob, block_size, training=None, scale=True):
    def drop():
        _, w, h, c = tf.shape(x)[0], tf.shape(x)[1], tf.shape(x)[2], tf.shape(x)[3]
        w, h = tf.to_float(w), tf.to_float(h)
        gamma = (1. - keep_prob) * (w * h) / (block_size ** 2) / ((w - block_size + 1) * (h - block_size + 1))
        w, h = tf.to_int32(w), tf.to_int32(h)
        sampling_mask_shape = tf.stack([1, h - block_size + 1, w - block_size + 1, c])
        noise_dist = tf.distributions.Bernoulli(probs=gamma)
        mask = noise_dist.sample(sampling_mask_shape)

        br = (block_size - 1) // 2
        tl = (block_size - 1) - br
        pad_shape = [[0, 0], [tl, br], [tl, br], [0, 0]]
        mask = tf.pad(mask, pad_shape)
        mask = tf.nn.max_pool(mask, [1, block_size, block_size, 1], [1, 1, 1, 1], 'SAME')
        mask = tf.cast(1 - mask, tf.float32)
        output = tf.multiply(x, mask)
        output = tf.cond(tf.constant(scale, dtype=tf.bool) if isinstance(scale, bool) else scale,
                     true_fn=lambda: output * tf.to_float(tf.size(mask)) / tf.reduce_sum(mask),
                     false_fn=lambda: output)
        return output

    output = tf.cond(tf.logical_or(tf.logical_not(training), tf.equal(keep_prob, 1.0)),
                     true_fn=lambda: x, false_fn=drop)
    return output
h = dropblock(x=h, keep_prob=self.dropout, block_size=3, training=self.is_training, scale=True)
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
需要学习Windows系统YOLOv4的同学请前往《Windows版YOLOv4目标检测实战:原理与源码解析》,课程链接 https://edu.csdn.net/course/detail/29865【为什么要学习这门课】 Linux创始人Linus Torvalds有一句名言:Talk is cheap. Show me the code. 冗谈不够,放码过来!  代码阅读是从基础到提高的必由之路。尤其对深度学习,许多框架隐藏了神经网络底层的实现,只能在上层调包使用,对其内部原理很难认识清晰,不利于进一步优化和创新。YOLOv4是最近推出的基于深度学习的端到端实时目标检测方法。YOLOv4的实现darknet是使用C语言开发的轻型开源深度学习框架,依赖少,可移植性好,可以作为很好的代码阅读案例,让我们深入探究其实现原理。【课程内容与收获】 本课程将解析YOLOv4的实现原理和源码,具体内容包括:- YOLOv4目标检测原理- 神经网络及darknet的C语言实现,尤其是反向传播的梯度求解和误差计算- 代码阅读工具及方法- 深度学习计算的利器:BLAS和GEMM- GPU的CUDA编程方法及在darknet的应用- YOLOv4的程序流程- YOLOv4各层及关键技术的源码解析本课程将提供注释后的darknet的源码程序文件。【相关课程】 除本课程《YOLOv4目标检测:原理与源码解析》外,本人推出了有关YOLOv4目标检测的系列课程,包括:《YOLOv4目标检测实战:训练自己的数据集》《YOLOv4-tiny目标检测实战:训练自己的数据集》《YOLOv4目标检测实战:人脸口罩佩戴检测》《YOLOv4目标检测实战:中国交通标志识别》建议先学习一门YOLOv4实战课程,对YOLOv4的使用方法了解以后再学习本课程。【YOLOv4网络模型架构图】 下图由白勇老师绘制  
The deep learning toolbox includes various software libraries, frameworks, and tools that help developers and researchers build and train deep neural networks. Some of the popular deep learning toolboxes are: 1. TensorFlow: Developed by Google, TensorFlow is an open-source deep learning library that supports building and training neural networks for various applications. 2. PyTorch: Developed by Facebook, PyTorch is an open-source deep learning framework that provides a flexible platform for building and training neural networks. 3. Keras: Keras is a high-level neural networks API that runs on top of TensorFlow, Theano, or Microsoft Cognitive Toolkit. It simplifies the process of building deep learning models and enables fast experimentation. 4. Caffe: Caffe is an open-source framework for deep learning that is widely used for image recognition and classification tasks. 5. MXNet: Apache MXNet is an open-source deep learning framework that supports multiple programming languages and provides a scalable and efficient platform for building and training neural networks. 6. Torch: Torch is an open-source scientific computing framework that provides a range of tools and modules for building and training deep neural networks. 7. Theano: Theano is a Python library that enables efficient mathematical computations and supports building and training neural networks. These toolboxes enable developers and researchers to create complex deep learning models with ease and efficiency. They provide pre-built modules, functions, and algorithms that can be customized to suit specific requirements.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值