pyxis.py 文件源码

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

项目:ml-pyxis 作者: vicolab 项目源码 文件源码
def get_sample(self, i):
        """Return the ith sample from `data_db`.

        Parameter
        ---------
        i : int
        """
        if 0 > i or self.nb_samples <= i:
            raise IndexError('The selected sample number is out of range: %d'
                             % i)

        # Convert the sample number to a string with trailing zeros
        key = encode_str('{:010}'.format(i))

        with self._lmdb_env.begin(db=self.data_db) as txn:
            # Read msgpack from LMDB and decode each value in it
            obj = msgpack.unpackb(txn.get(key))
            for k in obj:
                # Keys are stored as byte objects (hence the `decode_str`)
                obj[decode_str(k)] = msgpack.unpackb(
                    obj.pop(k), object_hook=decode_data)

        return obj
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号