rbm.py 文件源码

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

项目:neurotools 作者: michaelerule 项目源码 文件源码
def hashfloat128(x,N):
    '''
    Convert a bit vector to a float128
    Not to be confused with `pylab.packbits`

    Parameters
    ----------
    x : boolean or binary vector
    N : positive integer, number of bits in each vector
    Returns
    -------
    float128 : integer, stored in float128, whose binary bits match x
    '''
    x = (np.array(x)!=0)
    if not x.shape[-1]==N:
        raise ValueError('The last dimension of x should match the bit vector length N')
    if N>63:
        raise ValueError('No more than 63 bits are safe at the moment')
    return x.dot(2**np.float128(np.arange(N)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号