weight_init.py 文件源码

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

项目:nn_mask 作者: ZitengWang 项目源码 文件源码
def uniform(size, low=None, high=None, dtype=numpy.float32):
    if dtype is numpy.float32 or dtype is numpy.float64:
        if low is None:
            low = -numpy.sqrt(6. / sum(size))
        if high is None:
            high = numpy.sqrt(6. / sum(size))
        return numpy.asarray(
                numpy.random.uniform(
                        low=low,
                        high=high,
                        size=size
                ),
                dtype=dtype)
    elif dtype is numpy.complex64:
        return (uniform(size, low=low, high=high, dtype=numpy.float32) +
                1j * uniform(size, low=low, high=high,
                             dtype=numpy.float32)).astype(numpy.complex64)
    elif dtype is numpy.complex128:
        return (uniform(size, low=low, high=high, dtype=numpy.float64) +
                1j * uniform(size, low=low, high=high,
                             dtype=numpy.float64)).astype(numpy.complex128)
    else:
        raise ValueError('Requested dtype not available.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号