MiniBatchLoader.py 文件源码

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

项目:ga-reader 作者: bdhingra 项目源码 文件源码
def build_bins(self, questions):
        """
        returns a dictionary
            key: document length (rounded to the powers of two)
            value: indexes of questions with document length equal to key
        """
        # round the input to the nearest power of two
        round_to_power = lambda x: 2**(int(np.log2(x-1))+1)

        doc_len = map(lambda x:round_to_power(len(x[0])), questions)
        bins = {}
        for i, l in enumerate(doc_len):
            if l not in bins:
                bins[l] = []
            bins[l].append(i)

        return bins
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号