rbm.py 文件源码

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

项目:neurotools 作者: michaelerule 项目源码 文件源码
def unhashfloat128(x,N):
    '''
    Unpack bits from number b; inverse of `hashbits()`
    Not to be confused with `pylab.unpackbits`

    Parameters
    ----------
    x : float128 
        integer stored in float128, whose binary bits match x
    N : positive integer, number of bits in each vector

    Returns
    -------
    b : boolean or binary vector, unpacked
    '''
    if not x.dtype==np.float128:
        raise ValueError('Expected to unpack bit data from np.float128')
    x = x.copy()
    b = []
    for i in range(N):
        b.append(x%2)
        x = np.floor(x*0.5)
    b = (np.uint8(b)==1)
    return b.T
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号