深度学习之(八):dropout理解

深度学习之(八):dropout理解

  1. inverted dropout
    代码示例,以代码来理解原理
if mode == 'train':
    ###########################################################################
    # TODO: Implement the training phase forward pass for inverted dropout.   #
    # Store the dropout mask in the mask variable.                            #
    ###########################################################################
    mask = (np.random.rand(*x.shape) >= p) / (1 - p)        				#rescale
    #mask = (np.random.rand(x.shape[1]) >= p) / (1 - p)
    out = x * mask
    #pass
    ###########################################################################
    #                            END OF YOUR CODE                             #
    ###########################################################################
  elif mode == 'test':
    ###########################################################################
    # TODO: Implement the test phase forward pass for inverted dropout.       #
    ###########################################################################
    out = x
    #pass

难点理解主要在于resale上,解释如下:
在这里插入图片描述
注意:dropout可以理解为进行稀疏操作,在使用时主要用于全连接层;而对于卷积而言,由于其本身则是一种稀疏的特征提取方式,所以在卷积网络中一般不使用。

参考博客:
https://blog.csdn.net/fu6543210/article/details/84450890

猜你喜欢

转载自blog.csdn.net/yangwangnndd/article/details/89713880