mc_models.py 文件源码

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

项目:mediachain-indexer 作者: mediachain 项目源码 文件源码
def hsh_to_patches(self, hsh):

        pp = extract_patches_2d(hsh.astype(int), (self.patch_size, self.patch_size))

        # flatten 2nd and 3rd dimension:

        pp = pp.reshape((pp.shape[0], -1))

        # extract sample of patches:

        max_patches = min(self.max_patches, pp.shape[0])
        rr = [pp[x] for x in np.linspace(0, pp.shape[0], max_patches, endpoint=False).astype(int)]

        # pack patches into numbers:

        packed = [int(binascii.b2a_hex(''.join(np.packbits(x).view('c'))) or '0', 16) for x in rr]

        return packed
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号