dataset.py 文件源码

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

项目:Lyssandra 作者: ektormak 项目源码 文件源码
def get_mmap(X):
    """
    converts a numpy array to
    a numpy memmory mapped array
    """
    #TODO: use tempfile.NamedTemporaryFile
    if type(X) is np.core.memmap:
        return X
    fid = 0
    filename = mmap_base+"data"+str(fid)+".dat"
    for i in range(max_mmap_files):
        if os.path.isfile(filename):
            fid += 1
            filename = mmap_base+"data"+str(fid)+".dat"
        else:
            break

    _X = np.memmap(filename, dtype='float64', mode='w+', shape=X.shape)
    _X[:] = X[:]
    del X
    import gc
    gc.collect()
    return _X
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号