data_provider.py 文件源码

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

项目:painters 作者: inejc 项目源码 文件源码
def _split_into_groups(y, num_groups):
    groups = [[] for _ in range(num_groups)]
    group_index = 0

    for cls in set(y):
        this_cls_indices = np.where(y == cls)[0]
        num_cls_samples = len(this_cls_indices)

        num_cls_split_groups = ceil(num_cls_samples / 500)
        split = np.array_split(this_cls_indices, num_cls_split_groups)

        for cls_group in split:
            groups[group_index] = np.hstack((groups[group_index], cls_group))
            group_index = (group_index + 1) % num_groups

    return groups
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号