samplers.py 文件源码

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

项目:torchsample 作者: ncullen93 项目源码 文件源码
def gen_sample_array(self):
        try:
            from sklearn.model_selection import StratifiedShuffleSplit
        except:
            print('Need scikit-learn for this functionality')
        import numpy as np

        s = StratifiedShuffleSplit(n_splits=self.n_splits, test_size=0.5)
        X = th.randn(self.class_vector.size(0),2).numpy()
        y = self.class_vector.numpy()
        s.get_n_splits(X, y)

        train_index, test_index = next(s.split(X, y))
        return np.hstack([train_index, test_index])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号