我是靠谱客的博主 美满柠檬,这篇文章主要介绍torch.utils.data.RandomSampler和torch.utils.data.SequentialSampler的区别输出结果:,现在分享给大家,希望可以做个参考。
sampler_train = torch.utils.data.RandomSampler(torch.arange(10))
for i in sampler_train:
print(i)
print('=================')
for k in sampler_train:
print(k)
print('--------------')
sampler_val = torch.utils.data.SequentialSampler(torch.arange(10))
for j in sampler_val:
print(j)
print('=================')
for l in sampler_val:
print(l)
# 从结果上可以看出来RandomSampler随机采样在使用的时候,每次调用输出的
# 顺序都不大一样。而SequentialSampler顺序采样,每次结果都一样
输出结果:
3
0
1
6
4
5
9
7
8
2
=================
5
9
6
0
3
4
1
7
8
2
--------------
0
1
2
3
4
5
6
7
8
9
=================
0
1
2
3
4
5
6
7
8
9
最后
以上就是美满柠檬最近收集整理的关于torch.utils.data.RandomSampler和torch.utils.data.SequentialSampler的区别输出结果:的全部内容,更多相关torch.utils.data.RandomSampler和torch.utils.data.SequentialSampler内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复