tools.py 文件源码

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

项目:learning-class-invariant-features 作者: sbelharbi 项目源码 文件源码
def add_noise(x):
    """Add random noise to images."""
    sz = x.shape
    mask = (x == 0) * 1.
    noise = np.random.rand(sz[0], sz[1])
    for i in range(x.shape[0]):
        noise[i] = ndimage.uniform_filter(noise[i].reshape(28, 28), size=3).flatten()
    noise = np.multiply(noise, mask)
    out = np.clip(x + noise, 0., 1.)
    return out
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号