在train.py第151-152行,代码是这样的:
if sampler is not None: sampler.set_epoch(epoch)
当我自定义main入口函数,想用RandomSampler采样时,就会报:RandomSampler没有set_epoch的方法
只有分布式采样时,才会有set_epoch方法,所以,更严谨的方法是:
if sampler is not None and isinstance(sampler, DistributedSampler): sampler.set_epoch(epoch)
在train.py第151-152行,代码是这样的:
if sampler is not None: sampler.set_epoch(epoch)
当我自定义main入口函数,想用RandomSampler采样时,就会报:RandomSampler没有set_epoch的方法 只有分布式采样时,才会有set_epoch方法,所以,更严谨的方法是:
if sampler is not None and isinstance(sampler, DistributedSampler): sampler.set_epoch(epoch)