layers.py 文件源码

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

项目:fold 作者: tensorflow 项目源码 文件源码
def _create_drop_path_choices(self):
    if not self._drop_path:  # Drop path was turned off.
      return np.zeros(shape=[len(self._choices)], dtype='int32')
    elif np.random.uniform() < self._p_local_drop_path:
      # Local drop-path (make each choice independantly at random.)
      choices = np.random.uniform(size=[len(self._choices)])
      drop_base = choices < self._p_drop_base_case
      drop_recursive = np.logical_and(
          choices < (self._p_drop_base_case + self._p_drop_recursive_case),
          np.logical_not(drop_base))
      return (np.int32(drop_base)*self._JUST_RECURSE +
              np.int32(drop_recursive)*self._JUST_BASE)
    else:
      # Global (pick a single column.)
      column = np.random.randint(self._fractal_block_depth)
      return np.array(
          [self._JUST_RECURSE if len(binary_seq) < column else self._JUST_BASE
           for _, binary_seq in self._choices],
          dtype='int32')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号