layers.py 文件源码

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

项目:gated_word_char_rlm 作者: nyu-dl 项目源码 文件源码
def dropout(state_before, is_train, trng):
    """ 
    dropout with p=0.5 

    Parameters
    ----------
    state_before  : theano 3d tensor, input data, dimensions: (num of time steps, batch size, dim of vector)
    is_train      : theano shared scalar, 0. = test/valid, 1. = train,
    trng          : random number generator

    Returns
    -------
    proj          : theano 3d tensor, output data, dimensions: (num of time steps, batch size, dim of vector)

    """
    proj = tensor.switch(is_train, 
                         state_before * trng.binomial(state_before.shape, p=0.5, n=1, dtype=state_before.dtype), 
                         state_before * 0.5)
    return proj
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号